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 is basic php?

0 Answers  


How many ways you can delete a session variable ?

6 Answers  


What are major variables in research?

0 Answers  


What is difference between include,require,include_once and require_once()?

0 Answers  


Tell me how to execute an sql query? How to fetch its result?

0 Answers  


How do I get csrf token?

0 Answers  


What is the value for this auto incremented field user_pri_id?

0 Answers  


List some array functions in php?

0 Answers  


Describe the security vulnerability of PHP?

0 Answers  


what is mean by portal

0 Answers  


What is difference between print_r and echo in php?

0 Answers  


Is salary fixed or variable cost?

0 Answers  


Categories