hansford Posted June 5, 2008 Share Posted June 5, 2008 need a pattern for an entire anchor tag containing specifically this URL: http://www.sedoparking.com or http://www.sedoparking.complusanystringattached ------------------------- <a href='http://www.sedoparking.com'>whatever is here</a> <A HREF='http://www.sedoparking.com'>whatever is here</A> <A HREF="http://www.sedoparking.com">whatever is here</A> <a href="http://www.sedoparking.com">whatever is here</a> <a href = 'http://www.sedoparking.com' >whatever is here</a> ----------------------------- $fil = file_get_contents('http://www.frozen.com');` $find="/<[aA]\s*[ahrefHREF]*\s*=\s*[\"\']http:\/\/www\.sedoparking\.com.*[\'\"]\s*>.*<\/[Aa]\s*>"; $ret = preg_match_all($find, $fil, $matches, PREG_SET_ORDER); echo $ret; // returns 0 any input or advice would be appreciated. Quote Link to comment Share on other sites More sharing options...
noon Posted June 5, 2008 Share Posted June 5, 2008 <a[^>]*(sedoparking.com){1}[^>]*>.*<\/a> This should work, use an ungreedy/case insensitive flag. A lookahead assertion would be cleaner than my double [^>]*'s but not really required Quote Link to comment Share on other sites More sharing options...
hansford Posted June 5, 2008 Author Share Posted June 5, 2008 That worked like a charm - thank you. Quote Link to comment Share on other sites More sharing options...
effigy Posted June 5, 2008 Share Posted June 5, 2008 The literal period should be \. and there's no need for {1}. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.