Re: What's the best way to extract HTML out of $var?
| From: | John Meyer | Date: | Fri, 15 Jan 2010 02:20:03 +0000 |
| Subject: | Re: What's the best way to extract HTML out of $var? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301127@lists.php.net to get a copy of this message | ||
On 1/14/2010 7:15 PM, alexus wrote:
> What's the best way to extract HTML out of $var?
>
> example of $var
>
> $var = "<a href="http://http://stackoverflow.com/"StackPt‡J
> *Æú)Œ“—©èÊ Overflow</a>"
> I want
>
> $var2 = "http://starckoverflow.com/"
> example: preg_match();
>
> what else?
>
Actually what it looks like you want are the URLs, not the HTML. This
regular expression will match them up for you:
https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?