From WikiChip
Difference between revisions of "mirc/identifiers/$regsub"
< mirc‎ | identifiers

(Created page with "{{mirc title|$regsub Identifier}}'''$regsub''' performs a regular expression match and then substitute/replace, returns the number of match found and store the result in a %va...")
 
(Parameters)
 
Line 9: Line 9:
 
* '''input''' - The input text
 
* '''input''' - The input text
 
* '''regex''' - The regular expression for {{mIRC|regex|PCRE}}
 
* '''regex''' - The regular expression for {{mIRC|regex|PCRE}}
* '''subtext''' - the text to use to replace the match, you cannot use {{mIRC|$regml}} or {{mIRC|$regmlex}} inside the subtext parameter nor you can use \1 etc, for that you need to use {{mIRC|$regsubex}}
+
* '''subtext''' - The text to use to replace the match, this parameter is evaluated once prior the regex call, you can use backreferences \1 \2 etc, but it doesn't support the markers of {{mIRC|$regsubex}} such as \t \n \A etc. , you cannot use {{mIRC|$regml}} or {{mIRC|$regmlex}} inside the subtext parameter since it's evaluated prior the regex call.
  
 
== Properties ==
 
== Properties ==

Latest revision as of 06:34, 15 December 2019

$regsub performs a regular expression match and then substitute/replace, returns the number of match found and store the result in a %var or &binvar, more information about regex in mIRC here


Synopsis[edit]

$regsub([name],input,regex,subtext,%var|&binvar)

Parameters[edit]

  • name - The optional name of the regex, to be used later to retrieve captured group with $regml or $regmlex
  • input - The input text
  • regex - The regular expression for PCRE
  • subtext - The text to use to replace the match, this parameter is evaluated once prior the regex call, you can use backreferences \1 \2 etc, but it doesn't support the markers of $regsubex such as \t \n \A etc. , you cannot use $regml or $regmlex inside the subtext parameter since it's evaluated prior the regex call.

Properties[edit]

None

Example[edit]

//var %a | echo -a $regsub(abcd,/[a-z]/g,1,%a)

Compatibility[edit]

Added: mIRC v5.9
Added on: 26 Apr 2001
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See Also[edit]