I’m having a string which is autogenerated by a third party web-service, where I want to get the URL from the string. The string looks like this:
'document.write("<div class=\"display_archive\"><div class=\"campaign\">20\/12\/2011 - <a href=\"http:\/\/us2.campaign-archive1.com\/?u=fdf89fgd7sdf7d8&id=ffd89dfef3\" title=\"News\" target=\"_blank\">News<\/a><\/div><\/div>");'
I want to retrieve the URL, in above case this URL: http://us2.campaign-archive1.com/?u=fdf89fgd7sdf7d8&id=ffd89dfef3\ and I want to remove escape backslashes so the URL is: http://us2.campaign-archive1.com/?u=fdf89fgd7sdf7d8&id=ffd89dfef3/
I’ve tried with some different parsers and Regex, but I’m not that strong in Regex and can’t seem to get the URL correctly. I tried this preg_match but it doesn’t work and is only returning empty arrays:
%^((http?://)|(www\.))([a-z0-9-].?)+(:[0-9]+)?(/.*)?$%i
Any help is much appreciated.
Sincere
- Mestika