开发者

Regular expression to validate name in .NET multilingual web application

开发者 https://www.devze.com 2022-12-26 06:04 出处:网络
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 s

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

0

精彩评论

暂无评论...
验证码 换一张
取 消