普通防爆pression拒绝不是逗号其它特殊字符 [英] Regular Expression to reject special characters other than commas

查看:172
本文介绍了普通防爆pression拒绝不是逗号其它特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中工作。我使用普通防爆pression验证

能否请你帮我在创造不容许的特殊字符不是逗号其他常规的前pression。逗号有就可以了。

我regexlib检查,但是我无法找到一个匹配。我TREID与 ^(A-Z | A-Z | 0-9)* [^#$%^&放大器; *()] * $ 。当我添加其他字符为无效,这是行不通的。

也可以请你建议我一个地方,我可以找到正规的前pressions的一个很好的资源? regexlib似乎要大;但任何其他地方,其中列出很有限的,但最常用的例子吗?

另外,我可以创建一个使用C#code EX pressions?对于任何文章?


解决方案

  [\\ W \\ S,] +

工作得很好,因为你可以看到波纹管。

RegExr 是一个伟大的地方提供实时结果,以测试你的正常前pressions,这也配备了常见的前pressions非常完整列表。

[] 字符类 \\ W 匹配任何单词字符(字母数字和放大器;下划线)。 \\ S
匹配任何空白字符(空格,制表符,换行符)。 包含逗号 + 是贪婪的匹配;这将1次或多次匹配previous。

I am working in asp.net. I am using Regular Expression Validator

Could you please help me in creating a regular expression for not allowing special characters other than comma. Comma has to be allowed.

I checked in regexlib, however I could not find a match. I treid with ^(a-z|A-Z|0-9)*[^#$%^&*()']*$ . When I add other characters as invalid, it does not work.

Also could you please suggest me a place where I can find a good resource of regular expressions? regexlib seems to be big; but any other place which lists very limited but most used examples?

Also, can I create expressions using C# code? Any articles for that?

解决方案

[\w\s,]+

works fine, as you can see bellow.

RegExr is a great place to test your regular expressions with real time results, it also comes with a very complete list of common expressions.

[] character class \w Matches any word character (alphanumeric & underscore). \s Matches any whitespace character (spaces, tabs, line breaks). , include comma + is greedy match; which will match the previous 1 or more times.

这篇关于普通防爆pression拒绝不是逗号其它特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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