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

242
Views
How to use regex lookahead with big conditions?

I want to detect things that start with @ and have a double bracket. @[uuid][displayValue]. I have the following regex for that.

@\[([^\][]*)]\[([^\][]*)]

I want to pair lookahead((?=) with it but doing that does not work.

(?=@\[([^\][]*)]\[([^\][]*)])

It does not return any match. Lookahead is to keep delimiter in javascript split function.

Consider the following example:

const text = 'I want to thank @[handle1][displayValue1], @[handle2][displayValue2] for their contribution'.

When I use text.split(/(?=@\[([^\][]*)]\[([^\][]*)])/g) with the regex, I am looking for following output

['I want to thank ','@[handle1][displayValue1]',', ','@[handle2][displayValue2],'for their contribution']
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

run the sniipet, and you get the matches with start indexes

for( let a of 'I want to thank @[handle1][displayValue1], @[handle2][displayValue2] for their contribution'.matchAll(/@\[(.*?)\]\[(.*?)\]/g)){console.log(a)}

enter image description here


if uuid/displayValue might contain @[][] like words, you will need to code more logic, probably with a finite state machine

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!