Regular Expression for Japanese characters

前端 未结 3 1590
-上瘾入骨i
-上瘾入骨i 2020-12-05 15:43

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 u

3条回答
  •  青春惊慌失措
    2020-12-05 16:25

    Here is a regular expression that can be used to match all English alphanumeric characters, Japanese katakana, hiragana, multibytes of alphanumerics (hankaku and zenkaku), and dashes:

    /[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]+|[々〆〤]+/u
    

    You can edit it to fit your needs, but notice the "u" flag at the end.

    I hope this helps!

提交回复
热议问题