Interview Questions

How can we extract string 'abc.com ' from a string http://info@abc.com using regular expression of php?

PHP Interview Questions and Answers


(Continued from previous question...)

How can we extract string 'abc.com ' from a string http://info@abc.com using regular expression of php?

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];

(Continued on next question...)

Other Interview Questions