You have all probably seen my post on my favorite regex of all time. But here's my second favorite regex of all time:

[,-.]

Any idea what this regexp matches? Scroll down for the answer.

.

.

.

.

.

.

.

.

.

It matches a comma, dash, and dot. But why is that interesting? Because when you have a regex with a dash in the middle, it means a range, and it also means a range here. However, a comma, dash, and dot are one after another in the ASCII table, so it matches a range from the comma to the dot, which includes the dash itself! In a way it's a self-matching regex!

Take a look at the ASCII table for a quicker visual understanding. See the comma, dash, and dot characters with blue background, they come one after another.

[,-.] matches itself.

See you next time!