4

I want to include all strings starting from a to m. This can be done using [a-m]* regex but I don't want a case where the string starts with "deal_string". What is the regular expression for this?

Test cases:

assets/filename.ext           -> pass
deal_string/filename.ext      -> fail
deal_string.ext               -> fail
deal_string_1.ext             -> fail
deal_draft.txt                -> pass
assets_deal_string.txt        -> pass
bombay.txt                    -> pass
zombie.srt                    -> fail
some_deal_string.txt          -> fail
zobie_special_string.txt      -> fail
yesuagg
  • 153
  • 1
  • 2
  • 9

1 Answers1

5

Use a Negative Lookahead here. If you want to match all strings that begin with a through m excluding the strings that begin with "deal_string", you can use:.

^(?!deal_string)[a-m].*$

Live Demo

hwnd
  • 69,796
  • 4
  • 95
  • 132