I don't know if this will actually help you or not, But I figured it might
help someone someday. Lol

If your using MSSQL and pulling the data your looking to strip from a
database, than you can actually do this from a mssql user defined function.



-- FIRST, RUN THE CODE BELOW ONCE TO CREATE YOUR INITIAL FUNCTION

USE [yourDataBaseName] -- " yourDataBaseName"  
GO
/****** Strips html ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[stripHTML]
(@HTMLText NVARCHAR(MAX))
RETURNS NVARCHAR(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
        RETURN LTRIM(RTRIM(@HTMLText))
END

-- USAGE EXAMPLE
SELECT dbo.udf_StripHTML('<p><a href="">Test</a></p>') as noHtml

-- OR YOU COULD DO THIS
SELECT dbo.udf_StripHTML(table.column) noHTML
FROM table

I've found this very helpful. :)

Regards,
Paul Alkema
http://paulalkema.com/


-----Original Message-----
From: Tom Chiverton [mailto:tom.chiver...@halliwells.com] 
Sent: Tuesday, May 18, 2010 11:21 AM
To: cf-talk
Subject: Re: Remove html characters


On Tuesday 18 May 2010 15:33:01 you wrote:
> #REReplace(trim(MYTEXTSTRING), "<[^>]*>", "", "All")#

But if I say that this is < the other thing, which is > that thing, it'll go

all wrong...

-- 
Tom Chiverton
Helping to centrally extend industry-wide plug-and-play slick products as
part 
of the IT team of the year 2010, '09 and '08

****************************************************

This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and
Wales under registered number OC307980 whose registered office address is at
Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB.  A
list of members is available for inspection at the registered office
together with a list of those non members who are referred to as partners.
We use the word "partner" to refer to a member of the LLP, or an employee or
consultant with equivalent standing and qualifications. Regulated by the
Solicitors Regulation Authority.

CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may
be confidential or legally privileged.  If you are not the addressee you
must not read it and must not use any information contained in nor copy it
nor inform any person other than Halliwells LLP or the addressee of its
existence or contents.  If you have received this email in error please
delete it and notify Halliwells LLP IT Department on 0870 365 2500.

For more information about Halliwells LLP visit www.halliwells.co



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333783
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to