Regular Expression for Japanese characters(日文字符的正则表达式)
问题描述
我正在使用 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?
请帮帮我.
推荐答案
这是一个正则表达式,可用于匹配所有英文字母数字字符、日文片假名、平假名、多字节字母数字(hankaku 和 zenkaku)和破折号:
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
您可以根据需要对其进行编辑,但请注意末尾的u"标志.
You can edit it to fit your needs, but notice the "u" flag at the end.
我希望这会有所帮助!
这篇关于日文字符的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:日文字符的正则表达式
基础教程推荐
- 在 contenteditable 中精确拖放 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
