Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

123
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda