For anyone who is having trouble with regular expressions, I suggest you have a look at this site by Jeff Avallone. It takes a regular expression in the native (cryptic) format and produces a visual display of the same expression. For example,
^[a-z0-9_-]{3,16}$
becomes
and the pattern for an email address
^([a-z0-9_.-]+)@([\da-z.-]+).([a-z.]{2,6})$
becomes
One caveat - you will see
\d{3,5}
expanded as
which may seem incorrect at first glance, however, the 2...4 times
refers not to the number of digits but the number of extra "trips" back through the loop so if you have three digits you require two extra trips back through. I recently suggested to the author that he consider labelling the iterators something like 3...5 occurrences
which would be both clear and precise.
In any case, this is a valuable tool for debugging complex expressions.