I didn't like regular expressions, considering them as a strange and mysterious beast. But lately I've been forced to use all their powers, so I get used to them.
From my experience, if you want to understand regular expressions you just have to find good description, which I have found in O'Reilly book "C# 3.0" by Joseph and Ben Albahari. Very good chapter about regular expressions.
First, it has method test(string)
- which returns true if regular expression was found in the source text (matched), or false, if wasn't.
Second, it has method exec(string)
- which extracts everything that is matched. It returns array of results.
Third, and most important, we can use RegExp to do replacement in the string, by calling source_string.replace(regex, replace_string)
Below is the calculator which allows you to play with regular expressions. You should enter source text, regular expression, modifiers (which are used in replacement), and replacement expression. After that you will get results of calls to test, exec, and replace upon source text.
By default it extracts all digits which look like phone numbers and formats them.