sql - Strip HTML Tags Whilst Ignoring Greater than Less than Values <>? -
I am trying to strip HTML tags out of the string using a function. Everything is working fine until I get valid & lt; > Values I have used this code in the loop through HTML input and found the character after 0-9 and returned the value to the output string.
DECLARE @i INT = 0 DECLARE @ input string VARCHAR (50) = 'this lesson & lt; 50 'announcement @fix VARCHAR (2) while @i & lt; = 9 set start @fix = '& lt;' + Cast (@i VARCHAR), such as '%' @inputstring + @fix + '%' instead of @inputstring = (@inputstring, '& lt;' + cast (as @i VARCHAR) , '[[' + 'Cast (@i as VARCHAR)) set @fix =' & gt; ' + Cast (@i as VARCHAR) If @inputstring is not liked '%' + 'span' + @fix + '%' and @inputstring does not like '%' + 'LI' + @fix + '%' SET @ Instead of inputstring = (@inputstring, '& gt;' + cast (@i as VARCHAR), ']]' + cast (@i as VARCHAR) print @inputstring set @ i = @ i + 1 End
The problem arises when I have a valid tag, like after any number, & lt; SPAN & gt; 50 & lt; SPAN & gt;
In this case, the function can not find the closing tag and reduce the returned string. Is there a way around it?
I can simplify this, but can it work?
VARCHAR @inputstring declaration (50) = 'this lesson & lt; 50 Change '(REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (REPLACE (@inputstring,' ',' '),' & lt; / span & gt; ' , ''), ',' '),' & lt; / li & gt; ',' '),' & lt; UL & gt; ',' ',' & Lt ; '', '', '', '', '', '', '', '', '', '', '', & Lt; '') '& Gt;', ']]')
Comments
Post a Comment