Difference between revisions of "$remtok"

From Scriptwiki
Jump to: navigation, search
(not ready but want to save it)
 
m
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
Removes the Nth matching token from text.
 
Removes the Nth matching token from text.
 
  $remtok(text,token,N,C)
 
  $remtok(text,token,N,C)
 +
If N is 0, removes all matching tokens.
 +
 +
If N is not specified, removes the first matching token.
  
 
== Example ==
 
== Example ==
  [[echo]] -ag $remtok(This is a moo test, moo, 1, 32)
+
  [[echo]] -ag $remtok(This is a moo test,moo,1,32)
This echo's ''This is a test'', as ''moo'' is removed from the text.
+
This echoes ''This is a test'', as ''moo'' is removed from the text.
 +
 
 +
[[var]] %mytext = This word will remove a word
 +
var %token = word
 +
echo -ag $remtok(%mytext,%token,32)
 +
This example will remove the first instance of the word ''word'' and echo: ''This will remove a word''.
 +
 
 +
var %mytoks = House Tree Bear Ship
 +
var %mytoks = $remtok(%mytoks,Tree,32)
 +
echo -ag Ours tokens are now: %mytoks
 +
The above example shows how you can remove a token from a varible. Echoes ''Ours tokens are now: House Bear Ship''
 +
 
 +
var %mytext = lol some people lol too often in lol sentences, lol
 +
echo -ag $remtok(%mytext,lol,0,32)
 +
This example shows how you can remove all matching tokens in a string by using N = 0. Echoes ''some people too often in sentences,''
  
 
[[Category:Token Identifiers]]
 
[[Category:Token Identifiers]]
 
{{Stub}}
 

Latest revision as of 15:32, 23 May 2008

Removes the Nth matching token from text.

$remtok(text,token,N,C)

If N is 0, removes all matching tokens.

If N is not specified, removes the first matching token.

Example

echo -ag $remtok(This is a moo test,moo,1,32)

This echoes This is a test, as moo is removed from the text.

var %mytext = This word will remove a word
var %token = word
echo -ag $remtok(%mytext,%token,32)

This example will remove the first instance of the word word and echo: This will remove a word.

var %mytoks = House Tree Bear Ship
var %mytoks = $remtok(%mytoks,Tree,32)
echo -ag Ours tokens are now: %mytoks

The above example shows how you can remove a token from a varible. Echoes Ours tokens are now: House Bear Ship

var %mytext = lol some people lol too often in lol sentences, lol
echo -ag $remtok(%mytext,lol,0,32)

This example shows how you can remove all matching tokens in a string by using N = 0. Echoes some people too often in sentences,