This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a user defined function to remove all HTML tags from the string data of MySQL Server.
There are certain requirements like, store HTML document into the text column, but unfortunately it also contains HTML tags which required to remove.
I found a user defined function for removing all HTML Tags from the given string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
DELIMITER $$ CREATE FUNCTION fn_RemoveHTMLTag (HtmlString text) RETURNS text BEGIN DECLARE StartTag, EndTag INT DEFAULT 1; LOOP SET StartTag = LOCATE("<", HtmlString, StartTag); IF (!StartTag) THEN RETURN HtmlString; END IF; SET EndTag = LOCATE(">", HtmlString, StartTag); IF (!EndTag) THEN SET EndTag = StartTag; END IF; SET HtmlString = INSERT(HtmlString, StartTag, EndTag - StartTag + 1, ""); END LOOP; END; |
Sample Execution:
1 |
SELECT fn_RemoveHTMLTag(' This is a Database Research and Development '); |