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);
}

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

Created by Raymond Camden / Design by Justin Johnson