检查现有正则表达式中的特殊字符 [英] Check special chars in an existing regular expression
本文介绍了检查现有正则表达式中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
。*([a-zA-Z0-9]){2}。*是正则表达式,用于验证至少2个相同的alpha数字存在
如何使用相同的正则表达式检查特殊字符是否存在
我尝试过:
我使用2个正则表达式1进行特殊字符检查,第二个用于检查2个连续字母数字
.*([a-zA-Z0-9]){2}.* is the regular expression to validate atleast 2consicutive alpha numerics are present
How to check special characters are present using the same regular expression
What I have tried:
I have used 2 regular expression 1 for special char check and the second for checking 2 consecutive alpha numeric
推荐答案
这取决于条件的连接方式(OR
,AND
,AND
具有特定订单)。
2 alnum或至少一个特殊字符:
([a-zA-Z0-9] { 2})|([@#
It depends on how the conditions are connected (OR
,AND
,AND
with specific order).
2 alnum or at least one special character:
([a-zA-Z0-9]{2})|([@#
%^& *()_ +] +)
2 alnum后面至少有一个特殊的:
[a-zA-Z0-9] {2}。* [@#
%^&*()_+]+)
2 alnum followed somewhere by at least one special:
[a-zA-Z0-9]{2}.*[@#
%^& *()_ +] +
普通的<$没有通用解决方案c $ c> AND 不知道使用过的reg引擎。您可能会阅读 lookahead 以及如何为使用过的引擎实现该功能。可能的(未经测试的)解决方案:
(?= [^ @#
%^&*()_+]+
There is no general solution for a plainAND
without knowing the used regex engine. You might read about lookahead and how that is implemented for the used engine. A possible (untested) solution:
(?=[^@#
这篇关于检查现有正则表达式中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文