Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda