I did a search for this and found a guy with an unanswered post very much like this one. Here's the deal: I'm trying to make a php script parse html files to find links on the page. I am using the preg_ functions to do so. Currently my "find a link" pattern is:
$pattern = "/(?Ui)href\s=\s\"'(.).(php|html)[\"']/";
I then use this pattern in a preg_match_all function. This works ok, but I would like to improve it. I would like to use back references (http://www.php.net/manual/en/pcre.pattern.syntax.php#regexp.reference.back-references) so that it looks to close the href section with the same type of quotes that it opened with. That way href="...' would not match. The way the quotes are set up now, a line like a href="javascript:popUp('page.html')" would return href="javascript:popUp('. I know that a line like that wouldn't actually match because of the (?!javascript), but it's the best example I can come up with. I tried something like this:
$pattern = "/(?Ui)href\s=\s([\"'])(?!javascript🙂(.*).(php|html)\1/";
But that will not match anything at all. I tried \2 as well. Does anyone know how to get this going? Thanks for the help.