Recently I discovered, to my surprise, that JavaScript has no built-in support for Unicode regular expressions.
So how can I test a string for letters only, Unicode or ASCII?
Recently I discovered, to my surprise, that JavaScript has no built-in support for Unicode regular expressions.
So how can I test a string for letters only, Unicode or ASCII?
I'd recommend Steven Levithan's excellent XRegExp library, which has a Unicode plugin containing various Unicode character classes: http://xregexp.com/plugins/
Recently I discovered, to my surprise, that javascript has no builtin support for unicode regex.
This comes to a surprise to me as well because
alert(/\u00B6/.test("¶"));
prints true.
\uHHHH
notation is a JavaScript language feature. Unicode regex support means things like Unicode properties (\p{L}
), blocks (\p{InLatinExtendedA}
), and scripts (\p{Cyrillic}
). JavaScript regexes have nothing like that; you either have to use the XRegExp Unicode plugin, or switch to a different language. –
Finstad © 2022 - 2024 — McMap. All rights reserved.