Re: PHP regular expression
| From: | Justin Patrin | Date: | Thu, 11 Mar 2004 21:57:22 +0000 |
| Subject: | Re: PHP regular expression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-180215@lists.php.net to get a copy of this message | ||
Mike Mapsnac wrote:
Hello I found this function online and want to understand how it works. I don't understand "/^" and "$/". I know that "^" beginning of the string but what is "/^". Thanks function validEmail($email) { return preg_match("/^([a-zA-Z0-9])+([.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+)+[a-zA-Z0-9_-]$/",$email); } _________________________________________________________________ Fast. Reliable. Get MSN 9 Dial-up - 3 months for the price of 1! (Limited-time Offer) http://click.atdmt.com/AVE/go/onm00200361ave/direct/01/The / characters are the regex delimiters. This is a throwback to the Perl language. Basically, the / show where the beginning and end of the regex is. You *MUST* have them. After the last / you can put modifiers such as 'i' for case insensitive matching. You can also use other chars for delimiters, but I try to stick with / for consistency. -- paperCrane <Justin Patrin>