Multi-Byte Number Matching

I need to match multibyte 0123456789 characters from Japanese using regex.

[0-9] in this case does not work. How can I get this regex? This is my first foray into multibyte string matching.

UPDATE

Matching a 4 digit string, e.g. year of birth, was successful with both UTF-8 and UTF-8 using the following regex

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

+4
source share
2 answers

A regular expression equivalent to /[0-9]/ for these multibyte numbers in Javascript,

 /[\uff10-\uff19]/ 
+4
source
 var str = '0123456789'; console.log( str.match(new RegExp('[0-9]', 'g')), str.match(/[\uff10-\uff19]/g) ); //returns ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] both ways 

Be sure to save the .js file with the correct encoding (UTF-8) if you are using a non-episized version.

+3
source

Source: https://habr.com/ru/post/1496027/


All Articles