Regexp匹配序列,不包含单词列表(.NET)

时间:2012-08-03 05:39:39

标签: .net regex

搜索的原始文字:

/russia/moscow-region/moscow/mitino_m
/russia/moscow-region/moscow/planernaya_m
/russia/moscow-region/outside
/russia/moscow-region/moscow/otradnoe_m
/russia/moscow-region/outside/podol-sk
/russia/moscow-region/foreign/mexico
/russia/moscow-region/moscow
/russia/moscow-region/abrakadabra/u-lalala
/russia/moscow-region/outside/himki
/russia/moscow-region/moscow/preobrajenskaya_pl_m

Regexp在这里:

russia/moscow-region/(moscow|outside).*$

您可以在此处查看结果:http://www.myregextester.com/?r=7f93ce7f

我需要反转这个表达式以匹配" russia / moscow-region /"之后不包含单词moscow, outside的所有值。字符串值。如何改变?

1 个答案:

答案 0 :(得分:21)

将其分组为NOT:

russia/moscow-region/(?!(moscow|outside)).*