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

183
Views
regex js how to to exclude from a match two consecutive zeros?

I have the following regular expression

^[2-9][0-9]{3}-W([0-5][0-3]|(?!00))

https://regex101.com/r/OOCxzT/1

I need to exclude from the match a string with two consecutive 00 for instance

2022-W00

I added (?!00) but does not seem to work properly.

Any idea how to fix it?

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

0

Using the negative lookahead in the alternation ([0-5][0-3]|(?!00)) this part (?!00) will be true (giving you a partial match) if the first alternative does not match, and from the current position what is directly to the right is not 00

The lookahead should be right before the second match of the digits.

^[2-9][0-9]{3}-W(?!00)([0-5][0-3])

Regex demo

If you only want to match 2 digits, you can also append an anchor $

^[2-9][0-9]{3}-W(?!00)([0-5][0-3])$
about 4 years ago · Juan Pablo Isaza Report

0

Is this what you need ? or more digit after 'W' ?

^[2-9][0-9]{3}-W([0-5][1-3]|[1-5][0-3])
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!