简单的问题:现有的项目让我增加额外的字段(对这些领域的常规EX pressions额外的检查),以支持自定义输入表单。我需要添加一个新的形式,但不能改变这个项目如何工作的。这种形式可以让访问者进入他的名字和姓氏的首字母加。所以,正则表达式 ^ [A-ZA-Z] * $ 现在的工作只是罚款。 这时有人注意到它不会接受读音符号字符的输入。如Ömür A土耳其的名字没有被接受为有效。它需要被接受,尽管
Simple problem: an existing project allows me to add additional fields (with additional checks on those fields as regular expressions) to support custom input forms. And I need to add a new form but cannot change how this project works. This form allows a visitor to enter his first and last name plus initials. So the RegEx ^[a-zA-Z.]*$ worked just fine for now. Then someone noticed that it wouldn't accept diacritic characters as input. A Turkish name like Ömür was not accepted as valid. It needs to be accepted, though.
所以,我有两个选择:
既然我不能改变这个项目的code,我只有这两种选择。我想preFER选项2,但现在不知道正确的正则表达式应该是。 (该项目是用C#4.0。)
Since I cannot change the code of the project, I only have these two options. I would prefer option 2 but now wonder what the proper RegEx should be. (The project is written in C# 4.0.)
推荐答案您可以使用特定的UNI code转义的字母 - \ p {L〕(这将包括 A-ZA-Z 的取值范围):
You can use the specific Unicode escape for letters - \p{L} (this will include the A-Za-z ranges):
^[.\p{L}]*$
查看 regularex pressions.info :
\ p {L〕或\ p {}信
\p{L} or \p{Letter}
匹配具有财产信一个统一code code点。查看教程中的Uni code字符属性属性的完整列表。每个统一code code点有且只有一个属性。可使用的字符类中。
Matches a single Unicode code point that has the property "letter". See Unicode Character Properties in the tutorial for a complete list of properties. Each Unicode code point has exactly one property. Can be used inside character classes.
更多推荐
检查变音符号与常规的前pression
发布评论