开发者

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)).*
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜