无效字符的正则表达式. [英] Regular expression for invalid characters.
本文介绍了无效字符的正则表达式.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我有一组必须在字符串中允许的字符
允许的字符:"{} [] \; '':,./?! @#$%& *()_ +-=
不允许使用的字符为:〜〜^ | < >
任何机构都可以为我提供上述要求的正则表达式.
我试过了
Regex.IsMatch(@"^ [\〜| \`| \ ^ | \< | \>] * $")
但没有用.
Hi all
I have set of characters that has to be allowed in a string
Allowed charaters : '' { } [ ] \ ; '' : " , . / ? ! @ # $ % & * ( ) _ + - =
The characters that are not allowed are: ` ~ ^ | < >
can any body give me a regular expression for the above requirement.
I tried this
Regex.IsMatch(@"^[\~|\`|\^|\<|\>]*$")
but didn''t work.
It is also validating for an empty string.
推荐答案
%& *()_ +-=
不允许使用的字符为:〜〜^ | < >
任何机构都可以为我提供上述要求的正则表达式.
我试过了
Regex.IsMatch(@"^ [\〜| \`| \ ^ | \< | \>] *
% & * ( ) _ + - =
The characters that are not allowed are: ` ~ ^ | < >
can any body give me a regular expression for the above requirement.
I tried this
Regex.IsMatch(@"^[\~|\`|\^|\<|\>]*
")
但没有用.
")
but didn''t work.
It is also validating for an empty string.
我还没有加载Expresso,(或VS-不要问),所以未经测试,但是我建议您删除前导"^",后跟"
I haven''t got Expresso loaded, (or VS - don''t ask) so this is untested, but I suggest that you remove the leading ''^'', the trailing ''
这篇关于无效字符的正则表达式.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文