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

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

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