CFLib.org – Common Function Library Project

CharAt(str, pos)

Last updated August 27, 2001

author

Raymond Camden

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Returns the character at a certain position in a string.

Return Values:
Returns a character.

Example:

<CFSET STR = "This is the end.">
<CFOUTPUT>
2nd char: #CharAt(Str,2)#<BR>
4th char: #CharAt(Str,4)#<BR>
6th char: #CharAt(Str,6)#<BR>
8th char: #CharAt(Str,8)#<BR>
</CFOUTPUT>

Parameters:

Name Description Required
str String to be checked. Yes
pos Position to get character from. Yes

Full UDF Source:

/**
 * Returns the character at a certain position in a string.
 * 
 * @param str 	 String to be checked. 
 * @param pos 	 Position to get character from. 
 * @return Returns a character. 
 * @author Raymond Camden (ray@camdenfamily.com) 
 * @version 1, December 3, 2001 
 */
function CharAt(str,pos) {
    return Mid(str,pos,1);
}
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