| A Few Handy PHP Regular Expressions (RegEx) |
|
|
| Written by Handy PHP Administrator | |
| Thursday, 17 January 2008 | |
|
I frequently find that I am looking around the Internet for various Regular Expressions and sometimes I tend to have trouble finding just the right one.Then when I do, I use it and forget all about it! While I know quite a bit about regex, I haven't mastered the techniques and figure if someone else has already found the regex for what I need, it is easier and more time efficient to use that one. Again, the problem for me is that I usually forget what script I used what regex in and have to go look it up again or search through a bunch of scripts on my computer that I've forgotten about. So I've decided to use this article as a regex repository that I'll add useful expressions and links to resources that will help you with your regex needs. Before I begin, I want to list a number of very good Regular Expression resources:
Now for the regular expressions I've used:Email Address:
Domain Name 1: This only matched simple domain names
Domain Name 2: This only matches complex domain names '/^([a-zA-Z0-9-]+)\.[a-zA-Z]{2,3}\.[a-zA-Z]{2}$/'
Sub Domain: This will only match for a sub domain of the specified domain '/^[a-zA-Z0-9-]+\.realdomainname\.com$/'
Sub Domain: This will only match for a sub domain of the specified domain '/^[a-zA-Z0-9-]+\.realdomainname\.com$/'
|
|
| Last Updated ( Friday, 09 May 2008 ) |
| Next > |
|---|









