18

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?

Alexei
  • 1,289
  • 3
  • 19
  • 34
  • 4
    Duplicate of [this SO question](http://stackoverflow.com/questions/7820930/regex-how-to-exclude-single-word) and [this](http://stackoverflow.com/questions/10683718/how-to-exclude-a-string) and [this](http://stackoverflow.com/questions/8854817/regex-match-words-except-these) and [this](http://stackoverflow.com/questions/2404010/match-everything-except-for-specified-strings) and [this](http://stackoverflow.com/questions/2532008/regex-to-match-all-of-a-set-except-certain-ones) ... – O. R. Mapper Aug 03 '12 at 05:43
  • Wow.. I really should check that before I answer people :( – Simon Whitehead Aug 03 '12 at 05:43

1 Answers1

36

Group it as NOT:

russia/moscow-region/(?!(moscow|outside)).*
Simon Whitehead
  • 63,300
  • 9
  • 114
  • 138
  • 3
    Is this possible without a negative lookahead? My regex implementation does not support it. – Jonah Jul 22 '15 at 07:35