Reputation: 548
I wanted to find string that does not contains substrings (test,Test, back, Back, Down, down) and ends with _number e.g.
test_02.txt -- False
Final_test_02.txt -- False
final_02.txt -- True
final_3.txt -- True
final_17.txt -- True
Down-05.txt -- False
How to do this efficiently with Regular Expression. I am new to RegEx. I have tried
((.*)^(test|Test|back|Back|Down)(.*)_\d)
But it is not working.
Upvotes: 0
Views: 56
Reputation: 174706
Seems like you want something like this,
^(?!.*?(?:[Tt]est|[Bb]ack|[Dd]own)).*?_\d+\.[^.\n]+$
Use negative lookahead assertion to match the strings which won't contain a particular substring.
Upvotes: 2