gpt4 book ai didi

java - 字符串是否包含 ASCII zenkaku?

转载 作者:行者123 更新时间:2023-11-29 05:38:31 25 4
gpt4 key购买 nike

我想检查字符串(从密码类型字段收到)是否包含日语 Zenkaku 字符,但我不知道如何使用 Java 检查它。

最佳答案

您可以使用 Regular Expressions 来做到这一点并且,感谢 the work of this guy ,您已准备好所需的所有 RegEx。

这里是zenkaku相关的:

Regex for matching full-width Katakana (zenkaku 全角)
([ァ-ン])

Regex for matching full-width Numbers (zenkaku 全角)
([0-9])

Regex for matching full-width Letters (zenkaku 全角)
([A-z])

Regex for matching full-width (zenkaku) Katakana codespace characters (includes
non phonetic characters)
([ァ-ヶ])

编辑:添加@ChrisB comment问题:

Actually the regexes for hiragana and katakana are too restrictive.

e.g. the katakana regex would not match words containing the 長音符,
such as ユーザー and コンピューター.

Here are some more comprehensive regexes for hiragana and katakana:

  • Hiragana = [ぁ-ゔゞ゛゜ー] // 0x3041-0x3094, 0x309E, 0x309B, 0x309C, 0x30FC

  • Katakana = [ァ-・ヽヾ゛゜ー] // 0x30A1-0x30FB, 0x30FD, &#x30FE, 0x309B, 0x309C, 0x30FC

  • Hiragana or katakana = [ぁ-ゔゞァ-・ヽヾ゛゜ー] //0x3041-0x3094, 0x309E, 0x30A1-0x30FB, 0x30FD, &#x30FE, 0x309B, 0x309C, 0x30FC

关于java - 字符串是否包含 ASCII zenkaku?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18588207/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com