I need a regex to match strings that do not end in certain terms.
Input is a bunch of Class names, like Foo, FooImpl, FooTest, FooTestSuite, etc.
I want to match anything that does not end in Test, Tests, or TestSuite.
Should Match:
FooImpl FooTestImpl FooShould not match:
FooTest FooTestSuite FooTestsI just can't get this right. What I have now is wrong so I won't even bother posting it.
Try a negative lookbehind if your language supports it:
/(?<!Test)(<?!Tests)(<?!TestSuite)$/
Otherwise you can simulate a negative lookbehind using a negative lookahead:
/^(?!.*(?:Test|Tests|TestSuite)$).*$/
Rubular
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With