Possible Duplicate:
PHP String Manipulation: Extract hrefs
I am using php and have string with content =
<a href="www.something.com">Click here</a>
I need to get rid of everything except "www.something.com" I assume this can be done with regular expressions. Any help is appreciated! Thank you
Assuming that is ALWAYS the format of the variable, below should do the trick. If the content may not be a link, this won't work. Essentially it looks for data enclosed within two quotations.
Give this a whirl:
Result:
www.something.com
Updated: Now requires the quoting style to match, addressing the comment below.
This is very easy to do using SimpleXML:
I would suggest following code for this:
OUTPUT
This will take care of both single quote
'
and double quote"
in the href link.As probably you didn't meant your question that easy, but this does exactly what you're asking for:
$href
is:As a regular expression it can be expressed it as this is:
Is this helpful?