How can we extract string ?allinterview.com ? from a string
?http://info@allinterview.com? using regular expression of PHP?

Answers were Sorted based on User's Feedback



How can we extract string ?allinterview.com ? from a string ?http://info@allinterview.com? using re..

Answer / pinky

if (ereg("allinterview.com",
"http://info@allinterview.com", $temp) )

print $temp[0];

Is This Answer Correct ?    4 Yes 1 No

How can we extract string ?allinterview.com ? from a string ?http://info@allinterview.com? using re..

Answer / vipul dalwala

$string = "http://info@allinterview.com";
preg_match(@^(?:http://)?([^@]+)(.*)$@i', $string,
$matches);

print $matches[2]; // allinterview.com

Is This Answer Correct ?    3 Yes 2 No

How can we extract string ?allinterview.com ? from a string ?http://info@allinterview.com? using re..

Answer / raj

$text = "http://info@allinterview.com";
preg_match('|.*@([^?]*)|', $text, $output);
echo $output[1];

Is This Answer Correct ?    1 Yes 0 No

How can we extract string ?allinterview.com ? from a string ?http://info@allinterview.com? using re..

Answer / kichu

Using explode function

Is This Answer Correct ?    1 Yes 4 No

How can we extract string ?allinterview.com ? from a string ?http://info@allinterview.com? using re..

Answer / jcb.chl

<?
$str = substr('http://info@allinterview.com?',12);
echo $str;
?>

output:

allinterview.com?

Is This Answer Correct ?    2 Yes 6 No

How can we extract string ?allinterview.com ? from a string ?http://info@allinterview.com? using re..

Answer / iiiiiiii

iiiiiiii

Is This Answer Correct ?    0 Yes 7 No

Post New Answer

More PHP Interview Questions

Tell me how would you declare a function that receives one parameter name hello?

0 Answers  


What is interface? Why it is used?

0 Answers  


Can we use session in mvc?

0 Answers  


Explain how to run the interactive php shell from the command line interface?

0 Answers  


What is the difference between die () and exit () in php?

0 Answers  






What is the difference between indexed and associative array?

0 Answers  


What is full form of PHP?

0 Answers  


Explain what does the function get_magic_quotes_gpc() means?

0 Answers  


Is php worth learning in 2019?

0 Answers  


Why php is sometimes called as embedded scripting language?

0 Answers  


Difference between array_combine and array_merge?

0 Answers  


How does session work in php?

0 Answers  


Categories