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

124
Views
Regex in innerHTML to check for 2 numbers and one letter

I have an if statement in my Chrome extension that checks a page for listings to see if any match something in particular, such as:

if(matches[i].innerHTML.includes("12B"){

and that works fine. All said and done, the full return of matches[i].innerHTML will always be something like:

"12B Example"

So I'm primary interested in the initial 2 numbers, then a specific letter. So I want to add an additional check in the if statement to see if it matches any 2 numbers, then followed by the letter B specifically. Then after the B, I don't care what is there, I want it to be considered a match.

I tried the following:

if(matches[i].innerHTML.includes(/^[0-9]{2}[B]{1}/){

and that doesn't seem to be working. Is that sort of expression valid in setting?

I also tried: ([0-9]{2}[B]{1}) and similar. I looked here and in the documentation but wasn't able to find anything that gets me any further.

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

0

This regex will evaluate that there is 2 numbers and the B letter in capital at the beginning of the string, after that it will check if there's any other values or if it's empty.

if(matches[i].innerHTML.match(/^[0-9]{2}B.*$/)

Examples:

  • 12B
  • 01B46598
  • 99B46zAw%$
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!