DEV Community

Discussion on: Let's stop using [a-zA-Z]+

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

A while ago, I also learnt that JavaScript regex has unicode support (via /.../u).

I always had to use XRegExp before.

Also, the syntax is a little different. XRegExp('\\p{Han}') vs /\p{sc=Han}/u.

For this, I also recommend this VSCode extension, so that you don't write an invalid regex. (Like, valid in some compilers, but not native JavaScript.)

For /\p{Letter}/u, I would normally write shorthand.

/^[\p{L}\p{N}\p{M}-]+$/u
Enter fullscreen mode Exit fullscreen mode
Collapse
 
mcertan profile image
Mehmet Can Ertan

You are my savior

Collapse
 
steveconqueror1 profile image
Steve Kilonzo

This one really solved my problem