ملاحظة/مؤرشفة

المعرفة:: Regex المراجع:: https://stackoverflow.com/a/48902765

Unicode Property Escapes are among the features of ES2018.

Basic Usage

With Unicode Property Escapes, you can match a letter from any language with the following simple regular expression:

/\p{Letter}/u;

Or with the shorthand, even terser:

/\p{L}/u;

Matching Words

Regarding the question’s concrete use case (matching words), note that you can use Unicode Property Escapes in character classes, making it easy to match letters together with other word-characters like hyphens:

/[\p{L}-]/u;

Stitching it all together, you could match words of all[1] languages with this beautifully short RegEx:

/[\p{L}-]+/gu;