GetToken(string, index [, delimiters ])

Description

Returns a token in a string. Default delimiters are spaces, tabs, and newline characters. If index is greater than the number of tokens in string, GetToken returns an empty string.

Category

String functions

See also

Left, Right, Mid, SpanExcluding, SpanIncluding

Parameters

Parameter
Description
string
A string
index
An integer > 0 that indicates position of a token
delimiters
String that contains sets of delimiters

Example

<!--- This example shows the use of GetToken --->
<html>
<head>
<title>
GetToken Example
</title>
</head>

<body bgcolor = silver>
<H3>GetToken Example</H3>

<cfif IsDefined("FORM.yourString")>
<!--- set delimiter --->
<cfif FORM.yourDelimiter is not "">
    <cfset yourDelimiter = FORM.yourDelimiter>
<cfelse>
    <cfset yourDelimiter = " ">
</cfif>
<!--- check that number of elements in list is
greater than or equal to the element sought to return --->
<cfif ListLen(FORM.yourString, yourDelimiter) GTE FORM.returnElement>
    <cfoutput>
    <P>Element #FORM.ReturnElement# in #FORM.yourString#,
    delimited by "#yourDelimiter#"
    <BR>is:#GetToken(FORM.yourString, FORM.returnElement, yourDelimiter)#
    </cfoutput>
...