From WikiChip
$regsubex Identifier - mIRC
< mirc‎ | identifiers
Revision as of 10:34, 5 October 2018 by Ouims (talk | contribs)

$regsubex performs a regular expression match and then substitute/replace, just like $regsub, but it allows for markers in the replacement and return the substitutions immediatly by default, more information about regex in mIRC (and especially on $regsubex) here

Note: All the matches are made before the replacements, the total number of matches as well as any capture of any match can be accessed in the replacement with $regmlex

Note2: $regsubex returns the orignal input if there is no match found, if the /S modifier is used, the control code from the original input will be returned.

Synopsis

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

Parameters

  • 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, it can contains the following markers (markers can touch text, they are automatically enclosed in $+ if they touch text):
    • \0 - the total number of matches
    • \n - the current match number
    • \t - the 'matchtext', this is the same as $regml(\n), which is often misleading and not useful when you are using /g with multiple captures/backreferences, better to use \1
    • \a - all match, spaces seperated
    • \A - a non spaced version of \a
    • \1 \N etc - returns the same as $regmlex(\n,N), returns the value of the Nth captured group for that match

Properties

None

Example

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

Compatibility

Added: mIRC v6.17
Added on: 17 Feb 2006
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See Also