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).
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).
 
    
     
    
    ^(?!ABC$).*
matches all strings except ABC.
 
    
    Judging by you examples, I think you mean "all strings except those containing the word ABC".
Try this:
^(?!.*\bABC\b)
 
    
    You can simply invert the match using word boundaries and the specific string you want to reject. For example:
$ egrep --invert-match '\bABC\b' /tmp/corpus 
"A"     --> Match
"F"     --> Match
"AABC"  --> Match
"ABCC"  --> Match
"CBA"   --> Match
This works perfectly on your provided corpus. Your mileage may vary for other (or more complicated) use cases.
