Url finding regex
Posted: Fri Jan 25, 2008 7:59 pm
I wanted a regex to search a page for urls that are inside a html attribute.
I wrote this one, does it look good?
Is there any way to get around doubling the number of \?
I wrote this one, does it look good?
Is there any way to get around doubling the number of \?
Code: Select all
<?php
preg_match_all('/(?:(?:href|src|data|action)\s*=\s*(?:"(?:((?:\\\\.|[^\\\\])*?)")|\'(?:((?:\\\\.|[^\\\\])*?)\')|\s?(?:((?:\\\\.|[^\\\\])*?)(?:\s|>))))/is',$pagedata,$var,PREG_SET_ORDER);
?>