This post originated from an RSS feed registered with Java Buzz
by Paul Kilroy.
Original Post: Anatomy of a Regex
Feed Title: The Frustrated Programmer
Feed URL: http://liberty.phpwebhosting.com/404.html
Feed Description: The problems I encounter on a daily basis, blogged for posterity. All content will be original, contain poor grammar and a few mispellings.
In a recent post by Jason Bell, he asks for some help with a regex for validating email addresses. A commenter suggested this:
^[a-zA-Z0-9][_\\-\\.\\w]*@[\\w\\.\\-]+\\.[a-zA-Z]{2,4}$
If it makes sense I'm going to break it down into its pieces:
1) [a-zA-Z0-9] - Match 1 letter or number
2) [_\\-\\.\\w]* - Match 0 or more of: _ - . or a letter or number
3) @ - The @ character
4)