ted_chou12 Posted April 8, 2007 Share Posted April 8, 2007 I wish to know the string to use when you are using the function preg match, and grab the link in the a href of the html codes see the eg below: This is a <a href="link.php">link</a>, please visit! I wish to know how to get the link.php of the eg. shown using preg match function. Thanks Ted Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted April 8, 2007 Author Share Posted April 8, 2007 sorry, I wish to add something here, I want links of my own domain, so that: This is a <a href="link.php">link</a>, please visit! This is a <a href="http://mydomain.com/link.php">link</a>, please visit! This is a <a href="http://www.mydomain.com/link.php">link</a>, please visit! Will all work, however: This is a <a href="http://otherdomains.com/link.php">link</a>, please visit! This is a <a href="http://www.otherdomains.com/link.php">link</a>, please visit! will not work. and whatever form the link is in, I only want the link of my pages in the form link.php, or somedirectory/link.php. Thanks again. Ted Quote Link to comment Share on other sites More sharing options...
Wildbug Posted April 9, 2007 Share Posted April 9, 2007 Are you saying you only want links that point back to you to match? if (preg_match('|<a href="(?(?=http://)http://(?:www\.)?mydomain.com/)(.*?)">.*?</a>|',$value,$match)) echo "$match[1]\n"; Btw, "Talented," not "talanted." Quote Link to comment Share on other sites More sharing options...
Wildbug Posted April 9, 2007 Share Posted April 9, 2007 Actually, if you don't need the linked text, you can simplify that slightly: '|<a href="(?(?=http://)http://(?:www\.)?mydomain.com/)(.*?)">|' Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted April 9, 2007 Author Share Posted April 9, 2007 thanks, thats useful. 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.