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

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

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 Relatório

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 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