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
Answer / pinky
if (ereg("allinterview.com",
"http://info@allinterview.com", $temp) )
print $temp[0];
Is This Answer Correct ? | 4 Yes | 1 No |
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 |
Answer / raj
$text = "http://info@allinterview.com";
preg_match('|.*@([^?]*)|', $text, $output);
echo $output[1];
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / jcb.chl
<?
$str = substr('http://info@allinterview.com?',12);
echo $str;
?>
output:
allinterview.com?
Is This Answer Correct ? | 2 Yes | 6 No |
With a heredoc syntax, do I get variable substitution inside the heredoc contents?
What is a controller in programming?
Why many companies are switching their current business language to php?
What are sql functions?
What is mod_php?
how to run PHP in command line?
8 Answers InfoShore, Ramp Green, Xtreeme,
List out some tools through which we can draw E-R diagrams for mysql?
How do you define a constant?
Which functions are used to remove whitespaces from the string?
What is the Diff. Between echo() and Print() in PHP?
29 Answers CoreNet, Priya, QueenZend, Sky InfoTech, Syntel,
How to update memcached when you make changes to php?
What is php and why we use it?