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

249
Vistas
Javascript - how to replace an escape character followed by a 'G' in a string

I have the following string 'Ganaway\Gannaway\Gansway' from a text file where I need to replace the escape character(s) with ' or '.

I've found answers here on Stackoverflow that suggest:

const name = 'Ganaway\Gannaway\Gansway';
name.replace(/\//g, ' or ');

Fiddle

However when I debug it the name is already stripped automatically of the escape character before it reaches the .replace() code.

The result should be 'Ganaway or Gannaway or Gansway' but its unfortunately 'GanawayGannawayGansway'.

Update:

The strings originate from a GEDCOM file which was exported from a genealogy website called Ancestry.com - here are some examples of the original text, it's not only the 'G' but various others that lead to

Regular expression is invalid: PCRE does not support \L, \l, \N{name}, \U, or \u

errors:

1 NAME Emma Mae\May /Ganaway\Gannaway\Gansway/

or

1 NAME Niecy\Nicy Ann /Holy/

or

1 NAME Peggy Jo /Stewart\Uttrell/

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

0

You will have to use this syntax

const name = String.raw`Ganaway\Gannaway\Gansway`;
name.replace(/\\/g, ' or ');
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