问题
One of my project requirements is to validate a data field(text box from web page). I need to allow alpha numeric characters in all foreign languages (japanese,chinese,korean,russian,latin american characters etc). And avoid special characters.
I am using the expression /[^a-zA-Z0-9]/
(javascript, asp .net page)
Many blogs I have read and not able to correctly understand what exactly I have to do here. I can't add any addons or plugins and have to use the available functionality of regex.
How do regex engine recognize other language characters (esp. Unicode)?
回答1:
You will need to use Unicode
regular expressions. Please check this previous SO thread in which various unicode matching mechanisms are discussed.
来源:https://stackoverflow.com/questions/10006998/javascript-regex-for-validating-for-alphanumeric-characters-all-international-ch