2002-01-09 Update: Note to Posterity - there are better ways than this.
After posting this little thing (which truly was helpful for some),
two fine folks were kind enough to point out a
better way of understanding your regex and
a fine online reference - neither of which I had managed to locate on my own.
Many thanks to japhy for creating them and to tilly and crazyinsomniac for pointing them out.
If you're here looking to learn more about regular expressions, you'll do well to follow those links.
A new guy here was confused by the difference between
"capturing" with parens and "grouping" with brackets. I gave him this function to help show the difference, but it's useful for general testing of regular expressions.
The thing to remember is that it's easier to write a regex
that matches what you're looking for than it is to write
one that also doesn't match what you're not looking for.
Note: I did not use the 'quote regex' qr//; because that makes print display the regex in a way that differs from what the user typed. My goal here is clarity.
Further Reading (in increasing order of difficulty):