普通EX pression验证名称.N​​ET多语言Web应用程序 [英] Regular expression to validate name in .NET multilingual web application

查看:114
本文介绍了普通EX pression验证名称.N​​ET多语言Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能写一个正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

这篇关于普通EX pression验证名称.N​​ET多语言Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆