CFLib.org – Common Function Library Project

removeLinks(str)

Last updated August 11, 2005

author

Jen Wright

Version: 2 | Requires: CF5 | Library: StrLib

Description:
removeLinks searches a string for A tags and removes the tag and the closing tag. It takes one required argument, the string to be stripped. It returns the string with the links removed.

Return Values:
Returns a string.

Example:

<cfsavecontent variable="str">
<a href="http://www.cflib.org">CFlib.org</a><br>
More <b>test</b><br>
<a href="http://www.cnn.com">CNN.com
</a>
</cfsavecontent>

<cfoutput>#removeLinks(str)#</cfoutput>

Parameters:

Name Description Required
str String to parse. Yes

Full UDF Source:

/**
 * Strips links and closing link tags from a string.
 * Version 2 by Raymond Camden
 * 
 * @param str      String to parse. (Required)
 * @return Returns a string. 
 * @author Jen Wright (jen@jenw.net) 
 * @version 2, August 11, 2005 
 */
function removeLinks(str) {
    str = reReplace(str, "<[[:space:]]*[aA].*?>(.*?)<[[:space:]]*/[[:space:]]*a[[:space:]]*>","\1","all");
    return str;    
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson