$replace: Difference between revisions

From Scriptwiki
Jump to navigation Jump to search
Doomie (talk | contribs)
No edit summary
 
mNo edit summary
 
(2 intermediate revisions by one other user not shown)
Line 6: Line 6:
'''Note''' that if you have specified multiple replace parameter, it replaces one after another (see examples below). To avoid this, you can use [[$replacex]].
'''Note''' that if you have specified multiple replace parameter, it replaces one after another (see examples below). To avoid this, you can use [[$replacex]].


[[$replacecs]] is the case-sensitive version of $replace.
$replacecs is the case-sensitive version of $replace.


== Example ==
== Example ==
Line 22: Line 22:


== See Also ==
== See Also ==
Use [[$replacecs]] as case-sensitive version of $replace.
* [[$replacecs]] is case-sensitive version of $replace.
 
* [[$replacex]] (and [[$replacexcs]]) to avoid replacing an already replaced substring.
To avoid replacing an already replaced substring, you can use [[$replacex]] (or [[$replacexcs]]).


[[Category:Text_and_Number_Identifiers]]
[[Category:Text_and_Number_Identifiers]]

Latest revision as of 09:06, 2 July 2007

Replaces any occurrence of substring in string with newstring.

$replace(string,substring,newstring,...)

You can also specify multiple replace parameters.

Note that if you have specified multiple replace parameter, it replaces one after another (see examples below). To avoid this, you can use $replacex.

$replacecs is the case-sensitive version of $replace.

Example

; at first set an example text.
var %mytext = This is a test
; here we actually replace a substring
var %mynewtext = $replace(%mytext,is,MOO)
; echo the new text to the active window
echo -a %mynewtext

This example will echo ThMOO MOO a test, as all occurences of the substring is were replaced with MOO'.

var %mytext = This is a test
var %mynewtext = $replace(%mytext,is,MOO,mo,foo)
echo -a $replace(%mytext,is,MOO)

This on will echo ThfooO fooO a test as at first, all is were replaced with MOO and after that, all 'MO' were replaced with foo.

See Also