0
How can we extract string ‘abc.com ‘ from a string http://info@abc.com using regular expression of php?
Posted by The Blogger
on
12:21 PM
in
php
Answer 1:
We can use the preg_match() function with "/.*@(.*)$/" as
the regular expression pattern. For example:
preg_match("/.*@(.*)$/","http://info@abc.com",$data);
echo $data[1];
Answer 2:
you can use array split
$site_arr=split("@", "http://info@abc.com");
$site_name=$site_arr[1];
$site_name will have the value abc.com.
Answer 3:
Use this coding
$variablename="http://info@abc.com";
$u=explode("@",$variablename);
$u2=$u[1];
We can use the preg_match() function with "/.*@(.*)$/" as
the regular expression pattern. For example:
preg_match("/.*@(.*)$/","http://info@abc.com",$data);
echo $data[1];
Answer 2:
you can use array split
$site_arr=split("@", "http://info@abc.com");
$site_name=$site_arr[1];
$site_name will have the value abc.com.
Answer 3:
Use this coding
$variablename="http://info@abc.com";
$u=explode("@",$variablename);
$u2=$u[1];
Post a Comment