Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda