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




Answers were Sorted based on User's Feedback



How can we extract string 'abc.com' from a string "http://info@abc.com" using r..

Answer / 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

How can we extract string 'abc.com' from a string "http://info@abc.com" using r..

Answer / sameer joshi

You can do like $site_array=explod("@","http://info@abc.com");
$site_addr=$sitr_array[1];

$site_addr will get the value as abc.com

Is This Answer Correct ?    13 Yes 7 No

How can we extract string 'abc.com' from a string "http://info@abc.com" using r..

Answer / gaurav

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.

Is This Answer Correct ?    10 Yes 5 No




How can we extract string 'abc.com' from a string "http://info@abc.com" using r..

Answer / sathya

Use this coding

$variablename="http://info@abc.com";
$u=explode("@",$variablename);
$u2=$u[1];

Is This Answer Correct ?    7 Yes 4 No

How can we extract string 'abc.com' from a string "http://info@abc.com" using r..

Answer / nitesh kumar

you can use explode funciton

echo $site_array=end(explode("@","http://info@abc.com"));

Is This Answer Correct ?    4 Yes 2 No

How can we extract string 'abc.com' from a string "http://info@abc.com" using r..

Answer / navneet singh

$url = "http://info@abc.com"
$domain = strstr($url,"@");
echo $domain

Is This Answer Correct ?    5 Yes 7 No

Post New Answer



More PHP Interview Questions

What are the differences between Get and post methods in form submitting, give the case where we can use get and we can use post methods?

11 Answers   HCL, Rushmore Consultancy, Thursday Technology,


i am a php programmer can i be a java programmer?

3 Answers  


What is the basic function to search files for lines (or other units of text) that contain a pattern.

0 Answers  


which institute provide better PHP trainning in delhi? please tell me how much salary can freshers get ? thanku

5 Answers  


display selected value in dropdown list through javascript without page refresh

1 Answers  






What’s the difference between htmlentities() and htmlspecialchars()?

0 Answers  


Difference among echo, print and printf.

1 Answers  


How can we create a database using php?

0 Answers  


Dear Sir, i am a frasher and now i got a job offer from AentteQ Software Technologies for PHP developer.. so i am in confusion that is PHP correct for my carrer or i shud choose other then php for my carrer...plz suggest me

4 Answers   NIIT,


How can we convert the time zones using PHP?

1 Answers  


explain in brief type juggling in php?

1 Answers  


What is MIME?

2 Answers  






Categories