I am trying to replace every link of an HTML page so people can click on it. But I can't find the Regex for the pattern:
href="Any_URL" except those containing ".js" or ".css" ( in the middle or at the end of the URL)
I tried many patterns like href=".+(.css|.js){0}.*"
The idea is to get the content of a website and replace every URL ( except those containing .js and .css) by href="#" so people can't click on it.
$subject = file_get_contents($url, FILE_USE_INCLUDE_PATH); // get the content of the website
$pattern='#href=".+(.css|.js){0}.*"#i' // doesn't work
$page=preg_replace($pattern, 'href=#', $subject); // replace all the links by something not clickable
return $page;
{0}means match zero times, it doesn't mean to ensure it's not there. You would instead need to use an assertion, like\.(?!css|js)\w+- Niet the Dark Absol