CFLib.org – Common Function Library Project

Right2(string, length)

Last updated February 24, 2002

author

Jordan Clark

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Parameters are the same as right(). 0 Length returns no value. Negative lengths will return the the full string minus the specified number of characters from the left.

Return Values:
Returns a string.

Example:

<cfoutput>
right2( "CFlib.org", 0 ) = #right2( "CFlib.org", 0 )#<br>
right2( "CFlib.org", 3 ) = #right2( "CFlib.org", 3 )#<br>
right2( "CFlib.org", -2 ) = #right2( "CFlib.org", -2 )#<br>
</cfoutput>

Parameters:

Name Description Required
string The string to modify. Yes
length The length to use. Yes

Full UDF Source:

/**
 * Adds zero and negative support to the length parameter of right().
 * 
 * @param string 	 The string to modify. 
 * @param length 	 The length to use. 
 * @return Returns a string. 
 * @author Jordan Clark (JordanClark@Telus.net) 
 * @version 1, February 24, 2002 
 */
function right2( string, length )
{
  if( length GT 0 )
    return right( string, length );
  else if( length LT 0 )
    return right( string, len( string ) + length );
  else return "";
}
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