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

140
Vistas
Javascript regex with below validation rules

Allowable characters:

  1. uppercase A to Z
  2. lowercase a to z
  3. hyphen
  4. apostrophe
  5. single quote
  6. space
  7. full stop
  8. numerals 0 to 9

validations:

  • Must contain alphabetic characters
  • Cannot have consecutive non alpha characters except for full stop followed by a space OR apostrophe can be followed by a space
  • Cannot have non-alphabetic characters at the start (except for apostrophe)
  • Can end with a full stop

I have a regex with the below validation. Use this as reference

/^(?=[a-zA-Z0-9`'. -]+$)(?!.*[0-9'` -]{2})[a-zA-Z'][^\r\n.]*(?:\.[ a-z][^\r\n.]*)*$/;

Need to add the below validations to the above regex

  1. Can end with a full stop
  2. An apostrophe can be followed by a space.

Examples Valid

  1. 'Andy
  2. Andy.
  3. Andy' De'Wall
  4. Andy. DeWa2e
  5. A2dy'

Examples Invalid

  1. 2Andy
  2. A2'ndy.
  3. Andy'-Wall
  4. Andy. DeWa23
  5. A24dy'
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could:

  • assert not 2 consecutive digits . ' or -
  • assert not a digit or hyphen or space followed by a space
  • assert at least a char A-Z a-z
  • start the match with either ' or a char A-Z a-z

For example

^(?!.*[0-9.'-]{2})(?!.*[0-9 -] )(?=[^A-Za-z\n]*[A-Za-z])[A-Za-z'][A-Za-z0-9.' -]*$

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