Difference between revisions of "Tokenize"
From Scriptwiki
m (added $0) |
m |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | Fills the | + | Fills the $1 $2 ... $N identifiers with tokens in <text> separated by character c |
/tokenize <c> <text> | /tokenize <c> <text> | ||
Line 5: | Line 5: | ||
If you e.g. want to support different syntaxes, you can use /tokenize to bring it to a "standard format" (look at [[Weekday|this script]] to get an example). | If you e.g. want to support different syntaxes, you can use /tokenize to bring it to a "standard format" (look at [[Weekday|this script]] to get an example). | ||
+ | '''Note''' that the [[$0]] identifier is also filled with the total amount of tokens. | ||
== Example == | == Example == | ||
; set a test string | ; set a test string | ||
[[var]] %mystring = this.is.my.string | [[var]] %mystring = this.is.my.string | ||
; actually tokenize the string. 46 is the ascii number for . which is our seperator. | ; actually tokenize the string. 46 is the ascii number for . which is our seperator. | ||
− | tokenize 46 | + | tokenize 46 %mystring |
; lets loop through all $1, $2, $3 ... | ; lets loop through all $1, $2, $3 ... | ||
var %i = 1 | var %i = 1 | ||
Line 26: | Line 27: | ||
== See Also == | == See Also == | ||
− | + | * [[:Category:Token Identifiers|Token Identifiers]] for more information about tokens. | |
[[Category:Commands]] | [[Category:Commands]] |
Latest revision as of 09:12, 2 July 2007
Fills the $1 $2 ... $N identifiers with tokens in <text> separated by character c
/tokenize <c> <text>
If you e.g. want to support different syntaxes, you can use /tokenize to bring it to a "standard format" (look at this script to get an example).
Note that the $0 identifier is also filled with the total amount of tokens.
Example
; set a test string var %mystring = this.is.my.string ; actually tokenize the string. 46 is the ascii number for . which is our seperator. tokenize 46 %mystring ; lets loop through all $1, $2, $3 ... var %i = 1 ; $0 returns the total number of "$'s". while (%i <= $0) { ; echo the current "$". echo -a %i $+ : $ [ $+ [ %i ] ] ; increase looping variable inc %i }
This example will echo:
1: this 2: is 3: my 4: string
See Also
- Token Identifiers for more information about tokens.