标签:io ar sp on art cti 代码 html amp
代码中只是过滤了一部分标签,例如span这些还是没有过滤,如果有更好办法的,可以帮忙补充
create FUNCTION [dbo].[CleanHTML] (@HTMLText VARCHAR(MAX))
RETURNS VARCHAR(MAX) AS
BEGIN
DECLARE @Start INT
DECLARE @End INT
DECLARE @Length INT
SET @Start = CHARINDEX(‘<‘,@HTMLText)
SET @End = CHARINDEX(‘>‘,@HTMLText,CHARINDEX(‘<‘,@HTMLText))
SET @Length = (@End - @Start) + 1
WHILE @Start > 0 AND @End > 0 AND @Length > 0
BEGIN
SET @HTMLText = STUFF(@HTMLText,@Start,@Length,‘‘)
SET @Start = CHARINDEX(‘<‘,@HTMLText)
SET @End = CHARINDEX(‘>‘,@HTMLText,CHARINDEX(‘<‘,@HTMLText))
SET @Length = (@End - @Start) + 1
END
set @HTMLText=replace(@HTMLText,‘<‘,‘‘)
set @HTMLText=replace(@HTMLText,‘>‘,‘‘)
set @HTMLText=replace(@HTMLText,‘ ‘,‘‘)
RETURN LTRIM(RTRIM(@HTMLText))
END
标签:io ar sp on art cti 代码 html amp
原文地址:http://www.cnblogs.com/chlf/p/4049758.html