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

127
Vistas
Regex - Replace quote in quotes

The following regex pattern finds the a single double quote in the following string examples (basically the double quote after the 1). The problem is that the positive lookbehind is not supported in some browsers. Is there an alternative regex pattern that would work? I need to replace this double quote with another character using js (eg with a ? character).

(?<=(\w|"))"+(?![\s])

abc-1"-def321

"abc-1"-def321"

"aloha"

Desired results (replace double quote with a ? character):

abc-1?-def321

"abc-1?-def321"

"aloha"

Thanks.

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

0

I suggest

.replace(/([\w"])"+(?=\S)/g, '$1?')

See the regex demo. Details:

  • ([\w"]) - Capturing group 1: a word or " char
  • "+ - one or more " chars
  • (?=\S) - followed with a non-whitespace char.

See the JavaScript demo:

const text = `abc-1"-def321
"abc-1"-def321"
"aloha"`;
console.log(text.replace(/([\w"])"+(?=\S)/g, '$1?'));

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