Web lists-archives.org

Re: [PHP] Regex in PHP




You can use this:
$str = 'xxxx@xxxxxxxxx';

preg_match('/[^@]+@(.+)/', $str, $matches);
var_dump($matches);    //will be in $matches[1]


Or without regex:
echo substr($str, strpos($str, '@')+1);

Liran

----- Original Message ----- From: "VamVan" <vamseevan@xxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Wednesday, June 04, 2008 3:39 AM
Subject: [PHP] Regex in PHP


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

Thanks



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php