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.
我希望这会有所帮助!
这篇关于日文字符的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:日文字符的正则表达式


基础教程推荐
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 直接将值设置为滑块 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01