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;	
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson