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. Link to comment https://forums.phpfreaks.com/topic/108828-solved-need-a-regex-pattern/ 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 Link to comment https://forums.phpfreaks.com/topic/108828-solved-need-a-regex-pattern/#findComment-558217 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. Link to comment https://forums.phpfreaks.com/topic/108828-solved-need-a-regex-pattern/#findComment-558227 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}. Link to comment https://forums.phpfreaks.com/topic/108828-solved-need-a-regex-pattern/#findComment-558277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.