Discriminate between overlapping text patterns

EDITED:
{
((Contains “ab”) && !(Contains “abc”))
}
OR {
(!(Contains “AB”) && (Contains “abc”))
}