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

87
Vistas
Match non-English words using Regex in JavaScript

Here is an example sentence:

क्या आप क्लोज़अप करते हैं 

I want to extract the first word क्या from this sentence using Regex. I can do so in English by using (^\w+) but that doesn't work with other alphabets.

How should I proceed?

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

0

You can add the u flag for Unicode support. That way you can specify patterns that include character properties, such as \p{N} for numbers in any language (Arabic, Chinese, ...).

const str = 'क्या आप क्लोज़अप करते हैं ';

console.log('Letters and accent marks: ' + str.match(/^[\p{L}\p{M}]+/u))
console.log('Anything but space: ' + str.match(/^[^\p{Zs}]+/u))

Result:

Letters and accent marks: क्या
Anything but space: क्या

Explanation:

  • both regex use ^ to anchor at the beginning
  • regex 1: [\p{L}\p{M}]+ - one or more letters and accent marks
  • regex 2: [^\p{Zs}]+ - anything that is not a space (includes all Unicode spaces)
  • the u flag enables Unicode so that you can use \p{...} Unicode patterns

See details at https://javascript.info/regexp-unicode

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use this regex to extract first word

^[\pL]+
about 4 years ago · Juan Pablo Isaza Denunciar

0

Try following regex

[^\x00-\x7F]+
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