Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!