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

230
Views
How to match and extract string matching regular expression

This is main string:

MR HI Government He PIHe9 Hanumana Ji 3-� fafer/ DOB : 01/01/1959 989 / Male 2094 7051 9541 ������ - ��� ����� �� 3�1���

I want to match and extract 2094 7051 9541 using regular expression

and regex pattern to find is:

^[2-9]{1}[0-9]{-3}\\s[0-9]{4}\\s[0-9]{4}$

I want to use javascript to match and extract string. But not able to find right syntax to it.

Any help would be appreciated.

Thanks, PD

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You can use

const regex = /\b[2-9]\d{3}\s\d{4}\s\d{4}\b/;

See the regex demo. Note the use of a regex literal that helps avoid double escaping backslashes.

Details

  • \b - a word boundary
  • [2-9] - a digit from 2 to 9
  • \d{3} - three digits
  • \s - a wjitespace
  • \d{4} - four digits
  • \s - a whitespace
  • \d{4} - four digits
  • \b - a word boundary.

The word boundaries avoid matching the number as part of another number/word.

about 4 years ago · Santiago Gelvez 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!