rjustify2(string, length)
Last updated December 21, 2011
Version: 0 | Requires: CF5 | Library: UtilityLib
Description:
This function mimics the rJustify function, but offers an optional third parameter to define the character to use for padding (if padding is necessary).
Return Values:
Returns a string.
Example:
<cfoutput>
#rjustify2("foobar",10,".")#<br> <!--- outputs: ....foobar --->
#rjustify2("foobar",5,"-")#<br> <!--- outputs: foobar --->
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
string | String to manipulate. | Yes |
length | Length of pad. | Yes |
Full UDF Source:
/**
* Same as built-in RJUSTIFY, but allows optional parameter character to pad with.
*
* @param string String to manipulate. (Required)
* @param length Length of pad. (Required)
* @return Returns a string.
* @author Al Everett (everett.al@gmail.com)
* @version 0, December 21, 2011
*/
function rjustify2(string,length) {
var padChar = " ";
if (arrayLen(arguments) GT 2) {
padChar=left(arguments[3],1);
}
return repeatString(padChar,max(0,arguments.length - len(arguments.string))) & arguments.string;
}
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