What is the difference between encasing part of a regular expression in () (parentheses) and doing it in [] (square brackets)?
How does this:
[a-z0
[a-z0-9] will match one of abcdefghijklmnopqrstuvwxyz0123456789. In other words, square brackets match exactly one character.
(a-z0-9) will match two characters, the first is one of abcdefghijklmnopqrstuvwxyz, the second is one of 0123456789, just as if the parenthesis weren't there. The () will allow you to read exactly which characters were matched. Parenthesis are also useful for OR'ing two expressions with the bar | character. For example, (a-z|0-9) will match one character -- any of the lowercase alpha or digit.