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

292
Vistas
How to allow use sign ' with regular expression?

At the momemnt I'm using this regular expression to validate address

(!/^[A-Za-z]/i.test(street))

When I use address like this - Esterwergen - it works.

But when I added the sign before the title - 'Esterwergen - it shows my error.

Ho I can modify my RegEx and allow to use this sign before the name?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

To allow an optional leading ', you'd change your regexp from

/^[A-Za-z]/

to

/^'?[A-Za-z]/

where the ? means "zero or one times".

If you want to allow the ' anywhere in your string,

/^['A-Za-z]/

would do the trick.

In addition, be sure that you realize that you're only checking the first character of the string as it is.

Right now you will allow Ester9ui4y6ewigkdlLNDSKJ#€=# :::.

To constrain that, you'll need the + quantifier and the $ (end-of-string) anchor.

/^[A-Za-z]+$/
about 4 years ago · Juan Pablo Isaza Denunciar

0

Lets see what is your RegExp targeting:

  • /^[A-Za-z]/i

  • ^: Asserts position at start of the string.

  • []: Match a single character depending on what's inside.

  • A-Z: Match uppercase letters from A to Z.

  • a-z: Match lowercase letters from a to z.

  • i: Case-insensitive.

Consider this:

  • Using [A-Za-z] along with i flag is redundant. Use /^[a-z]/i or /^[A-z]/ instead.

  • Using [a-zA-Z\u00C0-\u00FF] for example extends matching to latin characters using UNICODE syntax. See full UNICODE reference here.

  • Use /^['a-z]+/i to allow ' anywhere in the string.

  • Use /^'?[a-z]+/i to allow ' only at the beginning of the string. ? means '1 time or 0 times'.

To play around with RegExp you can use tools like this.

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