检查变音符号与常规的前pression

编程入门 行业动态 更新时间:2024-10-27 14:28:36
本文介绍了检查变音符号与常规的前pression的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

简单的问题:现有的项目让我增加额外的字段(对这些领域的常规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.

所以,我有两个选择:

  • 完全拆下检查,这将允许用户进入垃圾。
  • 在写一个正前pression,这也将包括音调符号的字母,但仍然没有数字,空格或其他非字母。
  • 既然我不能改变这个项目的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

    本文发布于:2023-06-10 16:30:44,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/615057.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:符号   常规   pression

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!