Monday, February 18, 2019

Find all strings except one string using regex





I want to match all strings except the string "ABC".
Example:



 "A"     --> Match
"F" --> Match
"AABC" --> Match
"ABCC" --> Match
"CBA" --> Match
"ABC" --> No match



I tried with [^ABC], but it ignores "CBA" (and others).


Answer



^(?!ABC$).*


matches all strings except ABC.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...