Search code examples
javascriptregexmultibyte

Regex match multibyte numbers


I need to match multi-byte 0123456789 characters from Japanese using a regular expression.

[0-9] does not work in this case. How can I got about making this regex? This is my first foray into matching multi-byte strings.

UPDATE

Matching a 4 digit string, such as birth year, was successful with both UTF-8 and non UTF-8 using the following regex

^([0-9]{4}||[\uFF10-\uFF19]{4})$


Solution

  • The regex equivalent to /[0-9]/ for these multi-byte numbers in Javascript is

    /[\uff10-\uff19]/