Your Ad Here
0

How can we extract string ‘abc.com ‘ from a string http://info@abc.com using regular expression of php?

Posted by The Blogger on 12:21 PM in
Answer 1:

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

Answer 2:

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.

Answer 3:

Use this coding

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

tags: php interview questions and answers, php interview question How can we extract string ‘abc.com ‘ from a string http://info@abc.com using regular expression of php, How can we extract string ‘abc.com ‘ from a string http://info@abc.com using regular expression of php

0 Comments

Post a Comment

Your Ad Here

Copyright © 2009 Interview Questions and Answers