I usually do something like this (untested):
str = REreplaceNoCase(str, "<(/?)(b|i|strong|p)", "#chr(5)#\1\2", "all");
str = REreplaceNoCase(str,"</?[^>]*>","","all");
str = replace(str, chr(5), "<", "all");
Wrap it up in a UDF that takes the list of allowed tags as a
parameter, and you can use it all over the place.
cheers,
barneyb
On Wed, 25 Aug 2004 09:51:52 -0700, Cassidy Symons <[EMAIL PROTECTED]> wrote:
> I've been testing this out and can't find a way to strip all HTML except
> certain tags...is there any sort of 'not' modifier in RegEx in CF5, so I
> could do something like:
>
> <cfset mytext =
> '#REReplaceNoCase(mytext,"</?(NOT{b,i,strong,p,etc...}[^>]*>","","all")#'>
>
> Which would leave in tags that aren't really harmful. Obviously if need
> be I can just replace those tags with some sort of code (that hopefully
> doesn't happen to appear elsewhere in the text), run the RegEx function
> to strip all other HTML, then switch the codes back to HTML, but that
> seems like a rather inelegant way of going about it, not to mention slow
> if this is being done to several text fields on the same page.
>
> Can ColdFusion's RegEx functions accomplish this, or am I going to have
> to figure out a workaround?
>
> Thanks.
>
> Cassidy
>
--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

