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

232
Views
How does a regex match the format like xxxx1111 in js?

I'm limiting the user to input a string contains four letters following with 4 digit of numbers, like the format qwer1234 in vue.js. I have tried the regex b[a-z]{4}+[0-9]{4}\b but it seems not working. Are there any mistake I make?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

4 lowercase characters would be:

  • [a-z]{4}

4 digits would be

  • \d{4}

a word boundary is

  • \b

the start or end of a line are marked like this:

  • ^...$

So, if this phrase should be contained (possibly only as a part) of a bigger phrase, put word boundaries around it.

  • \b[a-z]{4}\d{4}\b

or if the entire phrase has to match exactly, then you can put it between start and end characters.

  • ^[a-z]{4}\d{4}$
over 4 years ago · Santiago Trujillo Report

0

I deleted the '+', and it works!

var pattern = /\b[a-z]{4}[0-9]{4}\b/;
var str = "";
console.log(pattern.test(str));
over 4 years ago · Santiago Trujillo 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!