Re: [PHP] Regex in PHP
- Date: Tue, 3 Jun 2008 23:32:09 -0400
- From: "Nathan Nobbe" <quickshiftin@xxxxxxxxx>
- Subject: Re: [PHP] Regex in PHP
On Tue, Jun 3, 2008 at 8:39 PM, VamVan <vamseevan@xxxxxxxxx> wrote:
> Hello All,
>
> For example I have these email addressess -
>
> xxxx@xxxxxxxxx
> xxxx@xxxxxxxxxxx
> xxxx@xxxxxxxxx
>
> What would be my PHP function[Regular expression[ to that can give me some
> thing like
>
> yahoo.com
> hotmail.com
> gmail.com
if you know the values are valid email addresses, use a combination of
strripos() and substr(). it will be nice a fast that way.
as an aside, this is what the manual says on preg_match()
Do not use *preg_match()* if you only want to check if one string is
contained in another string. Use
strpos()<http://www.php.net/manual/en/function.strpos.php>or
strstr() <http://www.php.net/manual/en/function.strstr.php> instead as they
will be faster.
and the case insensitive versions are a hair faster still ;)
-nathan