Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
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 answers
Answer question

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 Report

0

You can use this regex to extract first word

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

0

Try following regex

[^\x00-\x7F]+
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!