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?
U (Unicode dependent), and re. X (verbose), for the entire regular expression. (The flags are described in Module Contents.) This is useful if you wish to include the flags as part of the regular expression, instead of passing a flag argument to the re.
\u000d — Carriage return — \r. \u2028 — Line separator. \u2029 — Paragraph separator.
\p{L} matches a single code point in the category "letter". \p{N} matches any kind of numeric character in any script. Source: regular-expressions.info.
Therefore, the regular expression \s matches a single whitespace character, while \s+ will match one or more whitespace characters.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With