How do I write reciprocal link check regular expression? function isReciprocal() { $page =$this->_fetchUrl('http://'.$this->backward_link); $re="<a(.*)?href=\"http://(.*)?".$this->our_url."(.*)\""; return preg_match(")$re)i", $page); } PHP: But code above not works everywhere, couldnot check such links <a href='LINK'> etc. Maybe someones knows good RE?
That regular expression looks like it should work... as long as $this->our_url doesn't contain http://. If you just want to be able to match single and double quotes, you could change it to this... $re="<a(.*)?href=[\"']?http://(.*)?".$this->our_url."(.*)[\"']?"; PHP:
Any reason why a simple ereg wont work here? function isReciprocal() { $page =$this->_fetchUrl('http://'.$this->backward_link); if (eregi($this->our_url,$page)) { return 1; } else { return 0; } } PHP: ... or something like that. If fetchUrl() returns a string (I assume it does), maybe one of the substring type functions might also be useful.