Except
Except[pat]
matches all expressions except those that match pat
.
Except[pat1, pat2]
matches all expressions that match pat2
but not pat1
.
Attributes[Except] := {Protected}
Simple examples
In[1]:= Cases[{5, 2, 3.5, x, y, 4}, Except[_Real]] Out[1]= {5, 2, x, y, 4}
In[2]:= Cases[{5, 2, a^b, x, y, 4}, Except[_Symbol^_Symbol]] Out[2]= {5, 2, x, y, 4}
In[3]:= ({a, b, 0, 1, 2, x, y}) /. ((Except[0, a_Integer] -> foo[a])) Out[3]= {a, b, 0, foo[1], foo[2], x, y}