普通EX pression验证名称.N​​ET多语言Web应用程序应用程序、多语言、名称、普通

2023-09-04 00:50:27 作者:心之忧已,於我归息

我怎么能写一个正EX pression验证在多语言Web应用程序名称字段,我想验证的非英语语言如名称字段西班牙语或德语,我们需要确保没有人进入数字或特殊字符。我使用.NET 2.0

我相信我们能不能​​用EX pression如下的非英语语言。

  ^ [A-ZA-Z] {1,20} $
 

任何帮助将是非常美联社preciated!

我得到了这个普通防爆pression,它的工作原理FIEN当我使用正则表达式生成器但是当我尝试在实际的Web应用程序失败:

  ^ \ p {L〕[\ p {L〕\ p {PD} \ X27] * \ p {L〕$
 

解决方案

使用 \ W 的函。它是多语种的友好

how can i write a regular expression to validate name field in a multilingual web application, i want to validate the name field for non-English languages e.g. Spanish or German, and we need to make sure that no one enter digits or special characters. I'm using .NET 2.0

I believe we can't use expression as below for non-English language.

^[a-zA-Z]{1,20}$

Any help will be highly appreciated!

I got this Regular Expression, it works fien when i uses Regex Builder but when i try it in actual web application it fails:

^\p{L}[\p{L}\p{Pd}\x27]*\p{L}$

解决方案

use \w for letter. it is multilingual friendly