[英]Combining two regular expression
I have these two regular expression ,tried combining .But not working 我有这两个正则表达式,尝试结合使用。
Dim regExCheckLength As Regex = New Regex("^\w{10}$")
Dim regexCheckFormat As Regex = New Regex("\b(SSN|TC|EMP)")
I am new to reg ex,is there a way to combine 我是reg ex的新手,有没有办法合并
Use logical OR operator to combine both regexes. 使用逻辑OR运算符组合两个正则表达式。
Dim regExCheckLength As Regex = New Regex("^\w{10}$|\b(SSN|TC|EMP)")
To satisfy both, you need to use a positive lookahead like below, 为了满足这两个条件,您需要使用如下所示的正向前瞻,
Dim regExCheckLength As Regex = New Regex("^(?=\w{10}$).*\b(SSN|TC|EMP).*")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.