CFLib.org – Common Function Library Project

PadString(string, char, count)

Last updated August 16, 2001

author

Rob Brooks-Bilson

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Pads a string with n characters. Padding is from the left.

Return Values:
Returns a string.

Example:

<CFSET x=123>
<CFSET y="test">

<CFOUTPUT>
#PadString(x, 0, 4)#<BR>
#PadString(y, "a", 5)#
</CFOUTPUT>

Parameters:

Name Description Required
string String you want to pad. Yes
char Character to use as the padding. Yes
count Number of characters to pad the string with. Yes

Full UDF Source:

/**
 * Pads a string with n characters.  Padding is from the left.
 * 
 * @param string 	 String you want to pad. 
 * @param char 	 Character to use as the padding. 
 * @param count 	 Number of characters to pad the string with. 
 * @return Returns a string. 
 * @author Rob Brooks-Bilson (rbils@amkor.com) 
 * @version 1, August 16, 2001 
 */
function PadString(string, char, count)
{
  var Padding = RepeatString(char, count);
  return Padding & string;
}
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