Skip to main content
December 9, 2008
Question

replace

  • December 9, 2008
  • 4 replies
  • 731 views
I have string like that "<h2>test page</h2>" in the db.

I would like to remove <h2> and </h2> how can i do that... thanks
either sql server or coldfusion
This topic has been closed for replies.

4 replies

Inspiring
December 9, 2008
he he im just too fast for you, but it was worth you posting that function is much more substantial than the standard REReplace as it allows you to specify a specific tag.
Inspiring
December 10, 2008
Haha. Yes, too slow at the keyboard today ;-)
Inspiring
December 9, 2008
Oops. I did not see spill's response before replying ;-)
Inspiring
December 9, 2008
well you could run it twice, or use a regular expression to remove them. This will strip all html out of the string.

REReplaceNoCase(<h2>test page</h2>,"<[^>]*>","","ALL");
Inspiring
December 9, 2008
the replace function

#Replace("<h2>test page</h2>", "<h2>", "" ,"All")#
December 9, 2008
see how about </h2>. . dosn't go away
Inspiring
December 9, 2008
> I have string like that "<h2>test page</h2>" in the db.

For handling html, regular expressions are usually the best bet. Try one of the functions at cflib.org, such as:
http://www.cflib.org/index.cfm?event=page.udfbyid&udfid=1598

I have not tried that one, but there are several that do a good job with variable white space in tags (< / h2> ) and optional attributes.