Skip to main content
1 of 10
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375

I don't think that StringMatchQ["x", Except[{"*"}]] works as expected as well as StringMatchQ["x", Except["*"]]:

StringMatchQ["x", Except[{"*"}]]
StringMatchQ["x", Except["*"]]
True
True

The string pattern "*" is an abbreviated string pattern consisted from the only metacharacter * which corresponds to zero or more characters according to the first point under the "Details and Options" section of StringMatchQ. So by the definition the pattern Except["*"] shouldn't give a match at all because it means negation of literally everything. The current behavior is a bug.

This behavior is expected:

StringMatchQ["x", {"*"}]
StringMatchQ["x", "*"]
True
True
StringMatchQ["x", {"\\*"}]
StringMatchQ["x", "\\*"]    
False

False

But the following is another bug:

StringMatchQ["x", Except[{"\\*"}]]
StringMatchQ["x", Except["\\*"]]

StringExpression::invld: Element Except[{\}] is not a valid string or pattern element in Except[{\}]. >>

StringMatchQ["x", Except[{"\\*"}]]

StringExpression::invld: Element Except[\] is not a valid string or pattern element in Except[\]. >>

StringMatchQ["x", Except["\\*"]]
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375