CFLib.org – Common Function Library Project

CharAt(str, pos)

Last updated August 27, 2001

Version: 1 | Requires: ColdFusion 5 | Library: StrLib

 
Rated 1 time(s). Average Rating: 3.0

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

Return Values:
Returns a character.

Example:

view plain print about
<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:

view plain print about
<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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
3 day(s) ago

Will Belden Will Belden added
longTime
9 day(s) ago

James Sleeman James Sleeman added
quickSort
19 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
22 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson