When Regular Expressions Gets Greedy
I’ve been using a regular expression (PHP’s preg_match function) to parse email addresses. The addresses have a consistent pattern that look like:
anamehere+XXXXXXXX@mail.example.com
The XXXXXX section is a random set of characters: a-z, A-Z, 0-9 and -. The regular expression’s job was to extract that random set of characters, which is easy to do:
$email_addr = [...]
Read the rest of this entry »