singleLine(s)
Last updated December 13, 2010
Version: 0 | Requires: CF5 | Library: StrLib
Description:
Strips Tab, Line Feed, Form Feed, Carriage Return, and non-breaking space (ASCII 160) from strings. Reduces all space characters to a single occurrence.
Return Values:
Returns a string.
Example:
<cfset Test = "a#chr(10)#
b#chr(10)##chr(12)#
#CHR(9)##CHR(9)##CHR(9)#c#chr(13)#
#chr(32)##chr(32)##chr(32)##chr(32)##chr(32)#d#chr(13)#
#chr(160)##chr(160)##chr(160)##chr(160)##chr(160)#e">
<cfoutput>
multi-line<br>
<textarea>#Test#</textarea><br>
single line<br>
<textarea>#singleLine(test)#</textarea>
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
s | String to modify. | Yes |
Full UDF Source:
/**
* Strips characters that cause line wrap when exporting.
*
* @param s String to modify. (Required)
* @return Returns a string.
* @author James Moberg (james@ssmedia.com)
* @version 0, December 13, 2010
*/
function singleLine(s){
s = replacelist(s, "#chr(9)#,#chr(10)#,#chr(12)#,#chr(13)#,#chr(160)#", " , , , , ");
return trim(reReplace(s, "[[:space:]]{2,}", " ", "all"));
}
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