Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regexp match sequence that NOT contains list of words (.NET)

Tags:

.net

regex

Source text for search:

/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 is here:

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

you can see results right here: http://www.myregextester.com/?r=7f93ce7f

I need to inverse this expression to match all values that NOT contains words moscow, outside after "russia/moscow-region/" string value. How to change it?

like image 356
Alexei Avatar asked Aug 03 '12 05:08

Alexei


1 Answers

Group it as NOT:

russia/moscow-region/(?!(moscow|outside)).*
like image 170
Simon Whitehead Avatar answered Sep 26 '22 18:09

Simon Whitehead