问题描述
我正在Struts中进行国际化。我想为日语和英语用户编写Javascript验证。我知道英语的正则表达式,但不是日本用户。是否可以为基于Unicode验证的用户编写一个正则表达式?
I am doing internationalization in Struts. I want to write Javascript validation for Japanese and English users. I know regular expression for English but not for Japanese users. Is it possible to write one regular expression for both the users which validate on the basis of Unicode?
请帮帮我。
推荐答案
这个帖子可能很旧但只是认为我加了2美分。这是一个正则表达式,可用于匹配所有英语字母数字,日语片假名,平假名,字母数字[hankaku和zenkaku]的多字节,破折号
This thread may be old but just thought that I add my 2 cents. Here is a regular expression that can be used to match all English alphanumerics, Japanese katakana,hiragana,multibytes of alphanumerics [hankaku and zenkaku],dashes
/[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]+[々〆〤]+/u
您可以编辑它以满足您的需求,但请注意u标志位于结束。
You can edit it to fit your needs but notice the "u" flag at the end.
我希望这会有所帮助!
这篇关于日语字符的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!