1

I'm trying to validate this regular expression with JavaScript. What I need it to do is check if at least 2 words are entered. By words I mean strings with any characters except some specific. Everything is good until I end a string with a special unicode character, such as "ā". Then the expression fails to validate. Currently the expression looks like this - /^([^<>\\\/\?&{};#{}\+\*()"=%@,:0-9]{1,}\w){2,}$/i

Any ideas on how to validate unicode expressions in this case?

Deez
  • 829
  • 2
  • 9
  • 27

1 Answers1

0

On most programming lang, you would try this Unicode Regex:

/^([^<>\\\/\?&{};#{}\+\*()"=%@,:0-9\s]{1,}\p{L}){2,}$/ims

Or like this

/^([^\P]{1,}\p{L}){2,}$/ims

However, JS doesnt support Unicode that easily :(

See here for example: Javascript + Unicode regexes

Community
  • 1
  • 1
Raheel Hasan
  • 5,454
  • 4
  • 34
  • 65