0

i try to ceck a string without a tailing specified word. The word can contain a number at the end [0-9]+.

test test [match]
test test_word [not match]
test test_word9 [not match]
test test_word132 [not match]

The regex below work only for _word or _word1..._word9

.*(?<!_word|_word[0-9])$

Any suggestions?

  • Your solution is [here](http://stackoverflow.com/a/33868646/3832970). `^(?!.*_word[0-9]*$).*$` – Wiktor Stribiżew May 09 '17 at 13:14
  • You don't need to specify that the word can have a number at the end if you are looking ahead, it will work without it. Try this: `(?!test[ _]word)test` (sorry i made a mistake, correct version now) – Xyzk May 09 '17 at 13:16

0 Answers0