Here’s a little quiz to test your regex-fu. Suppose you want to match any of the strings
ab,cdab-cdab.cd
Someone proposes the regex ab[,-.]cd but you object that that’s incorrect because the - will be treated as specifying the range of characters between , and .. Oddly, the regex does match all three strings. Why is that?
See Paul Boyd’s post for the answer.
UPDATE :
I should have said that the regex matches all three strings and only those strings.