Useful regular expressions
Sunday, November 19th, 2006Everybody seems to have his own version of regular expressions for checking the validity of emails and URLs. I’ve combined serveral versions I found on the net to create my own.
Here’s the regular expression for checking the validity of email addresses:
^[a-zA-Z][w.-]*[a-zA-Z0-9]@[a-zA-Z0-9][w.-]*[a-zA-Z0-9].[a-zA-Z][a-zA-Z.]*[a-zA-Z]$
And here’s the regular expression for checking the validity of URLs:
^(http|https)://[a-z0-9]+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(([0-9]{1,5})?/?.*)$
These regular expressions should work [...]



