.NET正防爆pression从任何语言相匹配任何种类的信 [英] .net Regular Expression to match any kind of letter from any language

查看:140
本文介绍了.NET正防爆pression从任何语言相匹配任何种类的信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这经常EX pression我可以用它来搭配(允许)任何形式的字母,从任何语言

Which regular expression can I use to match (allow) any kind of letter from any language

我需要匹配任何字母,包括任何变音符号(如A,U,N等) 并排除任何一种符号(数学符号,货币符号,装饰符号箱绘制字符等)和标点字符。

I need to match any letter including any diacritics (e.g. á, ü, ñ, etc.) and exclude any kind of symbol (math symbols, currency signs, dingbats, box-drawing characters, etc.) and punctuation characters.

我使用asp.net MVC 2 .NET 4。我已经试过这个注释在我看来,型号:

I'm using asp.net MVC 2 with .net 4. I've tried this annotation in my view model:

[RegularExpression(@"\p{L}*", ...

和这一个:

[RegularExpression(@"\p{L}\p{M}*", ...

但客户端验证无法正常工作。

but client side validation does not work.

更新: 谢谢你所有的答案,您的建议工作,但只对.net和这里的问题是,它也采用了客户端验证的正则表达式使用JavaScript(抱歉,如果这还不够清楚)。 我只好去:

UPDATE: Thank you for all your answers, your suggestions work but only for .net and the problem here is that it also uses the regex for client side validation with JavaScript (sorry if this was not clear enough). I had to go with:

[^ 0-9_ \ |°¬#\ $%/ \()\¡¿+ {} []:?\; @ª^ *<> =&放大器;] *

这是非常丑陋,并不包括所有的情况反而是最接近我所需要的。

which is very ugly and does not cover all scenarios but is the closest thing to what I need.

推荐答案

有一点需要注意的是客户端的正则表达式。它使用在客户端和.NET正则表达式在服务器端JavaScript的正则表达式。 JavaScript就无法支持此方案。

One thing to watch out for is the client-side regex. It uses javascript regex on the client side and .net regex on the server side. Javascript won't support this scenario.

这篇关于.NET正防爆pression从任何语言相匹配任何种类的信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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