CFLib.org – Common Function Library Project

stripHTML(string)

Last updated July 9, 2008
Download UDF

author

Raymond Camden Raymond Camden

Version: 3 | Requires: ColdFusion 5 | Library: StrLib

 
Rated 12 time(s). Average Rating: 2.5

Description:
Returns the string with all HTML removed. Unlike HTMLEditFormat which escapes HTML, this function actually removes the HTML.

Return Values:
Returns a string.

Example:

<CFSET str="the <B>dog</B> jumped over the <A HREF=""foo.html"">fox</A>.">
<CFOUTPUT>
Given str=#str#<BR>
The StripHTML version is #StripHTML(str)#
</CFOUTPUT>

Parameters:

Name Description Required
string String to be modified. Yes

Full UDF Source:

<cfscript>
/**
* Removes HTML from the string.
* v2 - Mod by Steve Bryant to find trailing, half done HTML.
*
* @param string      String to be modified. (Required)
* @return Returns a string.
* @author Raymond Camden (ray@camdenfamily.com)
* @version 3, July 9, 2008
*/

function stripHTML(str) {
str = reReplaceNoCase(str, "<.*?>","","all");
//get partial html in front
str = reReplaceNoCase(str, "^.*?>","");
//get partial html at end
str = reReplaceNoCase(str, "<.*$","");
return str;
}
</cfscript>

Search CFLib.org


Latest Additions

Ryan Thompson-Jewell Ryan Thompson-Jewell added
ListSplit
3 day(s) ago

Nathan Dintenfass Nathan Dintenfass added
RowsToColumns
3 day(s) ago

Barney Boisvert Barney Boisvert added
indentXml
4 day(s) ago

Barney Boisvert Barney Boisvert added
REReplaceCallbac...
4 day(s) ago

Top Rated

Rob Brooks-Bilson                                 FolderSize
Rated 5.0, 7 time(s)

Nick Giovanni                                     UniqueValueList
Rated 5.0, 5 time(s)

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Jeff Howden ListDeleteDuplic...
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson