CFLib.org – Common Function Library Project

CharAt(str, pos)

Last updated August 27, 2001
Download UDF

author

Raymond Camden                                    Raymond Camden

Version: 1 | Requires: ColdFusion 5 | 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:

<cfscript>
/**
* 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);
}
</cfscript>

Search CFLib.org


Latest Additions

Jose Diaz-Salcedo Jose Diaz-Salcedo added
cfRssFeed
2 day(s) ago

Raymond Compton Raymond Compton added
structBlend
23 day(s) ago

Duncan Duncan added
IsZIPUK
23 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
29 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson