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

105
Vistas
Matching Arabic and English letters only javascript regex

I'm trying to write a regex that matches Arabic and English letters only (numbers and special characters are not allowed) spaces are allowed. This regex worked fine but allows numbers in the middle of the string

/[\u0620-\u064A\040a-zA-Z]+$/

for example, it matches (سم111111ر) which suppose not to match. The question is there a way not to match numbers in the middle of the letters.

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

0

Note in JavaScript you will have to use the ECMAScript 2018+ with Unicode category class support:

const texts = ['أسبوع أسبوع','week week','hunāka','سم111111ر'];
const re = /^(?:(?=[\p{Script=Arabic}A-Za-z])\p{L}|\s)+$/u;
for (const text of texts) {
    console.log(text, '=>', re.test(text))
}

The ^(?:(?=[\p{Script=Arabic}A-Za-z])\p{L}|\s)+$ means

  • ^ - start of string
  • (?: - start of a non-capturing group container:
    • (?=[\p{Script=Arabic}A-Za-z]) - a positive lookahead that requires a char from the Arabic script or an ASCII letter to occur immediately to the right of the current location
    • \p{L} - any Unicode letter (note \p{Alphabetic} includes a bit more "letter" chars, you may want to try it out)
    • | - or
    • \s - whitespace
  • )+ - repeat one or more times
  • $ - end of string.
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