Is there a way to pull details out of a regular expression’s failure?
I’m running into a situation where I’ve got some validation methods,
and I’m resorting to passing in both a regular expression and a range.
I know quite well I could just use a range inside of a regex, and
would rather, but I need to get the range in order to have some useful
For example, the string must be 3 to 8 characters long, start with a
letter, and may contain letters numbers or dashes.
I would like to just use this:
But if the match fails, I can’t give out any good error messages
without further inspecting the string, so I end up with
Just so I can give reasonable error messages.