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

238
Views
Regex for alphanumeric characters but all of which are not zero

Conditions:-

  1. Total length = 12
  2. First letter = A
  3. Second letter = B
  4. Rest of the 10 characters = Numbers or alphabets
  5. Rest of the 10 characters cannot be equal to 0000000000

Valid:-

  1. AB1234567890
  2. ABABABABABAB
  3. AB1234HIJ001

Invalid:-

  1. AB0000000000
  2. AB0
  3. AA1234567890

I have come up with this regex: '^[A-A][B-B][A-Z0-9]{10}$'. It prevents Invalid #2 and #3. But I'm having a hard time with Invalid #1. I know that to prevent all characters from being 0, I need to use '^0+$'. But how do I combine these two expressions?

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

0

You can add a negative lookahead to accomplish this: (?!0{10}).

^[A-A][B-B](?!0{10})[A-Z0-9]{10}$
           ^^^^^^^^^

regex101 demo

By the way, you don't need [A-A][B-B]. Just AB does exactly the same.

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!