Saturday 1 December 2018

html - regular expression to remove links

Regex is generally a bad solution for HTML parsing, a topic which gets discussed every time a question like this is asked. For example, the element could wrap onto another line, either as


  href="[variable content]">X

or


X


What are you trying to achieve?


Using JQuery you could disable the links with:


$("a.development").onclick = function() { return false; }

or


$("a.development").attr("href", "#");

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...