DEV Community

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

Collapse
 
lionelrowe profile image
lionel-rowe • Edited

Great post! But unfortunately, this still fails for some languages. For example, Burmese:

const burmese = 'မြန်မာဘာသာ'

;/^\p{Letter}+$/u.test(burmese) // false
Enter fullscreen mode Exit fullscreen mode

Or even certain normalized representations of "Lüdenscheid":

// visually the same, but splits the umlaut and the "u" into two characters
const town = 'Lüdenscheid'.normalize('NFD')

;/^\p{Letter}+$/u.test(town) // false
Enter fullscreen mode Exit fullscreen mode

You can get around this by also allowing the Mark category:

const regex = /^[\p{Letter}\p{Mark}]+$/u

regex.test(burmese) // true
regex.test(town) // true
Enter fullscreen mode Exit fullscreen mode
Collapse
 
tillsanders profile image
Till Sanders • Edited

Good remark! I will update the post to include this 👍