Difference between revisions of "$replacex"

From Scriptwiki
Jump to: navigation, search
(Added an example)
m
 
(One intermediate revision by one other user not shown)
Line 15: Line 15:
 
This example will echo ''Thmoo moo foo'' as at first ''is'' was replaced by ''moo'' and after that, all ''moo'' that are no replacement, replaced by ''foo''.
 
This example will echo ''Thmoo moo foo'' as at first ''is'' was replaced by ''moo'' and after that, all ''moo'' that are no replacement, replaced by ''foo''.
  
on @+1:rawmode:#: {
+
To reverse any changes a user makes to the channel, take a look at [[Undo_Modechanges|this script]].
  mode $chan $replacex($1,+,-,-,+) $iif($2,$2-)
 
}
 
This example will reverse any changes a user with user level 1 makes to the channel.
 
  
 
== See Also ==
 
== See Also ==
Take a look at [[$replacexcs]] for the case-sensitive version.
+
* [[$replacexcs]] is the case-sensitive version of $replacex.
 
+
* [[$replace]] (and [[$replacecs]]) for 'normal' replacing (inclusive already replaced substrings).
Use [[$replace]] (or [[$replacecs]]) for 'normal' replacing (inclusive already replaced substrings).
 
  
 
[[Category:Text_and_Number_Identifiers]]
 
[[Category:Text_and_Number_Identifiers]]

Latest revision as of 10:07, 2 July 2007

Replaces any occurrence of substring in string with newstring except for replacements that have already been made.

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

This is the same as $replace but it doesn't replace already replaced text (see example below).

$replacexcs is the case-sensitive version of $replaxce.

Example

; set a test text
var %mytext = This is moo
; actually replace substrings
var %mynewtext = $replacex(%mytext,is,moo,moo,foo)
; echo it to the active window
echo -a %mynewtext

This example will echo Thmoo moo foo as at first is was replaced by moo and after that, all moo that are no replacement, replaced by foo.

To reverse any changes a user makes to the channel, take a look at this script.

See Also

  • $replacexcs is the case-sensitive version of $replacex.
  • $replace (and $replacecs) for 'normal' replacing (inclusive already replaced substrings).