For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
CFML Reference / 

GetToken

Adobe Community Help


Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

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

Parameter

Description

string

A string or a variable that contains one. String in which to search.

index

Positive integer or a variable that contains one. The position of a token.

delimiters

A string or a variable that contains one. A delimited list of delimiters. Elements may consist of multiple characters.Default list of delimiters: space character, tab character, newline character; or their codes: "chr(32)", "chr(9)", chr(10). Default list delimiter: comma character.

Usage

The following examples show how this function works.

Example 1

In the following example, the function call requests element number 2 from the string, using the delimiter "[:;".

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

The output is as follows:

red,black,tan

Example 2

<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>
#HTMLCodeFormat(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(mystring, 3) is : #GetToken(mystring, 3)#
</cfoutput><br>

The output of this code is as follows:

GetToken(mystring, 3) is : nine,zero:;

The function finds the third delimiter, and returns the substring just before it that is between the second and third delimiter. This substring is ";".

Example 3

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

The output is as follows:

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

The following is a call against mystring2:

<cfoutput>
GetToken(mystring2, 2) is : #GetToken(mystring2, 2)#
</cfoutput>

The output is as follows:

GetToken(mystring2, 2) is : ,five,nine,zero:;

The function finds the second delimiter, and returns the substring just before it that is between the first and second delimiter. This substring is ",five,nine,zero:;".

Example

<h3>GetToken Example</h3>
<cfif IsDefined("FORM.yourString")>
<!--- set delimiter --->
<cfif FORM.yourDelimiter is not "">
<cfset yourDelimiter = FORM.yourDelimiter>
<cfelse>
<cfset yourDelimiter = " ">
</cfif>
<!--- check whether 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>
...

 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices