特殊字符的正则表达式验证 [英] Regular expression validation for special characters

查看:105
本文介绍了特殊字符的正则表达式验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想验证我的文本框和电子邮件字段不包含
>> << < > (){} []? &*〜`! #$%^ = + | \:``,;这些特殊字符,可以包含-_ @/.这些分隔字符.

我该怎么办?

预先感谢,
问候.

Hello All,


I want to validate my textbox and email fields not to contain
>> << < > ( ) { } [ ] ? & * ~ ` ! # $ % ^ = + | \ : '' " , ; these special characters and can contain - _ @ / . these sepcial characters.

How can i do it?

Thanks in advance,
Regards.

推荐答案

%^ = + | \:``,;这些特殊字符,可以包含-_ @/.这些分隔字符.

我该怎么办?

预先感谢,
问候.
% ^ = + | \ : '' " , ; these special characters and can contain - _ @ / . these sepcial characters.

How can i do it?

Thanks in advance,
Regards.


简单的正则表达式很容易:@"[^ \< \> ...]",其中的省略号是您要禁止的单个字符的列表.

但是,我建议更好的电子邮件地址验证是一个好主意,尤其是因为"@"不是电子邮件地址中的合法字符(这是域名和域名之间的分隔符本地地址,并且不能用于其他任何原因):请查看 [
The simple regex is easy: @"[^\<\>...]" where the elipsis is the list of individual characters you want to prohibit.

However, I would suggest that a better email address validation would be a good idea, especially since ''@'' is not a legal character in an email address (it is the separator between the domain and the local addresses and cannot be used for any other reason): have a look at this[^]


我建​​议使用以下免费软件:正则表达式事物
Expresso 3.0-首要的正则表达式开发工具 [
I recommend the following freeware to regular expression things
Expresso 3.0 - The premier regular expression development tool[^]


这篇关于特殊字符的正则表达式验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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