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.
GetToken(string, index [, delimiters ])
Left,
Right,
Mid,
SpanExcluding,
SpanIncluding
Parameter |
Description |
---|---|
string |
A string |
index |
An integer > 0 that indicates position of a token |
delimiters |
String that contains sets of delimiters |
<!--- 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> ...