GETTOKEN  
Description

Determines whether a token of the list in the delimiters parameter is present in a string.

 
Returns

The token found at position index of the string, as a string. If index is greater than the number of tokens in the string, returns an empty string.

 
Category

String functions

 
Function syntax
GetToken(string, index [, delimiters ])
 
See also

Left, Right, Mid, SpanExcluding, SpanIncluding

 
Parameters

 
Usage

The following examples show how this function works.

Example A: Consider the following code:

GetToken("red,blue:;red,black,tan:;red,pink,brown:;red,three", 2, ":;")

This function call requests element number 2 from the string, using the delimiter ":;". The output is as follows:

red,black,tan

Example B: Consider the following code:

<cfset mystring = "four," 
& #chr(32)# & #chr(9)# & #chr(10)# 
& ",five, nine,zero:;"
& #chr(10)# 
& "nine,ten:, eleven:;twelve:;thirteen," 
& #chr(32)# & #chr(9)# & #chr(10)# 
& ",four">
<cfoutput>
#mystring#<br><br>
</cfoutput>

The output is as follows:

four,
,five, nine,zero:;
nine,ten:, eleven:;twelve:;thirteen, 
,four

The GetToken function recognizes explicit spaces, tabs, or newline characters as the parameter delimiters (To specify a space character, the code is chr(32); a tab character, chr(9); and a newline character, chr(10).)

In the example string mystring, there is:

  • A forced space between the substrings "four," and ",five"
  • A literal space between "five," and "nine"
  • A literal space between "ten:," and "eleven,"
  • A forced space between "thirteen," and ",four"

In the following call against mystring, no spaces are specified in delimiters (it is omitted), so the function uses the space character as the string delimiter:

<br>
<cfoutput>
GetToken(mL)(
1XLjXL)(
Þ,%LjXL)&Ü*A>A0KÖj
{SÆLL)(
L jXL)(
Þ,%LjXL)&Ü*A580KÖj
{SÆLL)(
L(jXL)J(
Þ,%LjXL)&Ü*A580v×jþ{S
	Æ	LL)(
(L

L0jX(
L)Ã(
Þ%~
(
,(S
,%LjXL)&Ü*AEP%0v×jþ{S
	Æ	LL)(
(L

L8jX(
L)Ã(
Þ%~
(
,(S
,%LjXL)&Ü*AEP%0JØj~;-:{S
:LL)/+€9€;,%LjXL)&~9*0¢Újj
j,#(
(
LL)
(
{S:LL)
(
	LHjXL)Ä
(
(N
Þ4,%LjXL)&,%LjX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