Es token

From EventScripts Community Encyclopedia


Overview

Syntax: es_token <variable> <string> <token#> [seperator-character]

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Variation of this command that doesn't expand variables: {{{x}}}

Description

Sets a variable to the part of the string corresponding with token#. It splits up the string according to the seperator-character which defaults to space.

Parameters

  • variable - Variable where you want to store the token.
  • string - String that contains the tokens that you want to extract.
  • token# - Specific token that is extracted from the string.
  • seperator-character - Character that separates the tokens in the string. If this argument is omitted, a space is considered the separator.


Examples

//Example 1:
   es_xsetinfo mystring "This is the string that you're extracting the token from."
   es_xsetinfo token4 0
   es_xsetinfo token7 0
   es_token token4 server_var(mystring) 4  //will be "string"
   es_token token7 server_var(mystring) 7  //will be "extracting"
 
//Example 2:
   es_xsetinfo mystring "a=1,b=2,c=3,d=4,e=5"
   es_xsetinfo token2 0
   es_xsetinfo token5 0
   es_token token2 server_var(mystring) 2 ,  //will be "b=2"
   es_token token5 server_var(mystring) 5 ,  //will be "e=5" 


Notes

  • If you specify 0 for the token number, es_token will return the number of tokens in the string using that separator.


See also


External links

es_xtoken


{{{category}}}

blog comments powered by Disqus