15

用于搜索的源文本:

/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

正则表达式在这里:

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

你可以在这里看到结果:http ://www.myregextester.com/?r=7f93ce7f

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

4

1 回答 1

32

将其分组为 NOT:

russia/moscow-region/(?!(moscow|outside)).*
于 2012-08-03T05:42:41.113 回答