Why doesn't
Cases[{"a", "b"}, "a"~~___]
return {"a"} instead of {}?
I used three underscores. More detailed, why does 62 work, but 61 not
In Cases[{"abcde", "b"}, "a"~~__] Out[61]= {} In[62]:= StringMatchQ["abcde", "a" ~~ __] Out[62]= True
Duplicate MMa.SE thread with good discussion on the subject:
As Neil also said, you are mistaking regular patterns with string patterns. Cases takes a pattern (which can involve strings!), StringMatchQ takes string patterns.
Look at the documentation:
guide/Patterns tutorial/StringPatterns
In your case you can also use:
Select[{"a", "b"}, StringStartsQ["a"]]