I have returned a webpage through curl_exec into a string. I am trying to then replace all hyperlinks with the string javascript:void().
The regex expression that I have tested at http://regexhero.net/tester/ is
(?<=href=("|'))[^"']+(?=("|'))
This works perfectly. When I try and use it in PHP with preg_replace(), I get the error : Unknown mofifier '['
Code snippet is
$pattern = "(?<=href=(".'"'."|'))[^".'"'."']+(?=(".'"'."|'))";
$replacement = "javascript:void();";
$result = preg_replace($pattern,$replacement,$result) ;
I also tried just escaping the string like
$pattern = "(?<=href=(\"|'))[^\"']+(?=(\"|'))";
I am scripting in a Win environment, but it is to go on LAMP.
Thanks for your input
href=["'](\s*?)['"]