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

227
Vistas
I want to remove only one character before particular symbol for example:

I want to remove a specific character, as well as the one before it (in this case # and its preceding character). Example:

"ab#c" -> "ac"
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Use a regex and String.replace:

const inp = "ab#c";
const match = /.#/;
const out = inp.replace(match, "");

console.log(out);

Note that this removes any character preceding a '#' in your original string, but only a single occurrence. Add the g flag to match and replace all occurrences, and use [a-zA-Z] to just match letters.

If you want to work the other way (character following, not preceding), and want to replace #c but not \#c, just add that as well:

const inp = "ab\\#c3#cc";
const match = /[^\\]{1}#./;
const out = inp.replace(match, "");

console.log(out);

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use global regex replace

const inputStr = "ab#c de#f gh#i";

const regxStr = /.#/g;
const outputStr = inputStr.replace(regxStr, "");

console.log(outputStr);

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