regular expression to negate two conditions
I have two regular expressions:
".*-.*adm.*"
".*-svc"
Could someone explain how I can go about matching all of the strings which don't match/f开发者_开发百科it the two regular expression above?
Ps. Using vbscript
You would or the two expressions and then use Not
, like so.
Dim re
Set re = new regexp
re.Pattern = "(.*-.*adm.*)|(.*-svc)"
re.IgnoreCase = true
if Not re.Test(YOUR_STRING) then
' Do whatever
end if
I think negative lookahead is the tool you're looking for:
^(?![^-]*-(?:.*adm|svc)).*
精彩评论