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

396
Views
How do I implement a negative look-behind regular expression without using `(?<!)`?

I know about the negative look behind (?<!) operator, but it appears that the Javascript engine used in Expo/React-Native does not support it. What I want is to implement the following

export function processEmbedded(text: string): string {
  return text.replace(/(?<!!)\[Embedded\]/gm, "![Embedded]");
}

What I did was a bit hacky in that I stripped and re-added.

export function processEmbedded(text: string): string {
  return text
    .replace(/!\[Embedded\]/gm, "[Embedded]")
    .replace(/\[Embedded\]/gm, "![Embedded]");
}

For my cases it does work, but I am pretty sure there's an edge case where it does not.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You may use this work-around solution using a capture group:

export function processEmbedded(text: string): string {
  return text.replace(/(^|[^!])\[Embedded\]/gm, "$1![Embedded]");
}

RegEx Demo

(^|[^!]) matches start of line or a character that is not ! in first capture group. In the replacement we put it back using $1 back-reference.

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!