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

178
Visualizações
Regex to match substring containing 18 digits but don't match if it starts with @

I've looked for a solution and played around a bit with some examples but couldn't find what I'm looking for. (I'm using javascript)

Basically it should only match a string of 18 digits if the first character isn't @, it should only include the 18 digits.

So something like /[^@]\d{18}/g but if I do this it includes the first character that is not an @

Examples: test 123456789012345678 abc match 123456789012345678

test @123456789012345678 abc don't match.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

One option is to match an @ and a digit that you don't want, and then capture 18 digits between word boundaries \b in capture group 1 that you want to keep.

The word boundaries are to prevent a partial match for the digits.

@\d|\b(\d{18})\b

Regex demo

If supported, you can also use a negative lookbehind:

\b(?<!@)\d{18}\b

Regex demo

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