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

176
Views
Regex to match substring containing 18 digits but don't match if it starts with @

I've looked for a solution and played around a bit with some examples but couldn't find what I'm looking for. (I'm using javascript)

Basically it should only match a string of 18 digits if the first character isn't @, it should only include the 18 digits.

So something like /[^@]\d{18}/g but if I do this it includes the first character that is not an @

Examples: test 123456789012345678 abc match 123456789012345678

test @123456789012345678 abc don't match.

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

0

One option is to match an @ and a digit that you don't want, and then capture 18 digits between word boundaries \b in capture group 1 that you want to keep.

The word boundaries are to prevent a partial match for the digits.

@\d|\b(\d{18})\b

Regex demo

If supported, you can also use a negative lookbehind:

\b(?<!@)\d{18}\b

Regex demo

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!