Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

250
Vistas
How to remove specific multiple string and then remain another?
let result = 'Apple%00Juice%02';

const removeOne = result.slice(5, 8); // get %00

const removeTwo = result.slice(13, 16); // get %02

slice get the part of I want to remove not I want to get.

Is any function can let me get the result becomes to 'Apple Juice' ?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can get the desired result using a regex to match the parts you want to remove from the string and then replace them using the replace() method on strings.

const str = "Apple%00Juice%02";
const regex = /%\d+/g;

const result = str.replace(regex, " ").trim()

console.log(result);

Explanation of regex:

  • % - match the character % literally
  • \d+ - match any digit 0 to 9 one or more times
  • %\d+ - match % character followed by one or more digits
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can achieve this by using .replace() function

Example:

let result = 'Apple%00Juice%02';
result = result.replace('%00', ' ');
result = result.replace('%02', '');
console.log(result);

Read More About .replace() function at MDN Docs

Edit:

Minifying @Yousaf's Answer

let result = "Apple%00Juice%02";
result = result.replace(/%\d+/g, " ").trim()

console.log(result);

about 4 years ago · Juan Pablo Isaza Denunciar

0

It is possible with replace(), but that is not a sustainable solution. The URL encoding "% 00" is the � ASCII character. This suggests that the string is already being encoded in the wrong character format for the URL. So you have to look at the character format in which your database or file is read out. for example UTF-8, ISO 8859-1

When encoded in the correct character format. Can you decode it in JavaScript using the decodeURIComponent (str) method. more on this

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda