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

Answer Posted / rachana

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

Is This Answer Correct ?    49 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a lambda function in php?

610


What is Mcrypt used for?

585


Which is better php praogramming or cad/cam scope wise and also salaray wise?

1581


What is meant by ‘passing the variable by value and reference' in php?

536


Should I use mysqli or pdo?

521






Is php better than python?

557


How to repeat a string to a specific number of times in php?

534


How to Pass JSON Data in a URL using CURL in PHP?

573


What is escape data in php?

529


Where can I learn php?

534


What is the current stable version of php? What advance thing in php7?

526


How can we access the data sent through the url with the get method?

600


How to convert a string to lowercase in php?

575


How to track no of user logged in?

637


Is php fully object oriented?

495