$regsubex » History » Revision 7
Revision 6 (Per Amundsen, 06/30/2021 01:24 PM) → Revision 7/8 (Per Amundsen, 02/23/2023 07:29 PM)
_Added in 1.9.0_ *$regsubex([name], text, re, subtext, [%var|&binvar])* Performs a regular [[Scripting_Regex|regular expression]] and then performs a substitution using subtext. Returns the substituted text. _See also [[$regex]], [[$regsub]], [[$regml]], [[$regmlex]]. [[$regerrstr]]._ *Parameters* table(ktable). |*Parameter*|*Description*| | [name] | - Name of the search, which can later be referenced using [[$regml]]. (optional) | | text | - The text to search. | | re | - The [[Scripting_Regex<notextile>|</notextile>regular [[Scripting_Regex|regular expression]] to perform. | | subtext | - Subtext to replace with. | | [%var<notextile>|</notextile>&binvar] | [%var|&binvar] - Optionally output the text to a %var or a &binvar. ([name] must be defined and returns the number of matches instead of the substituted text) | *Subtext* The subtext evaluates identifiers before performing the substitution and special markers can be used to reference various parts of the result. *Subtext* table(ktable). |*Character*|*Description*| | \0 | - Returns the number of matches. | | \n | - Returns the current match number. | | \t | - Returns the current match text (same as [[$regml]](\n)). | | \a | - Returns all matching items. | | \A | - Returns a non-spaced version of \a. | | \@ | - Returns the total number of matches. *(AdiIRC only)* | | \1 \2 \N ... | - Returns the Nth back-reference made for a given match | *Example* <pre> ; Find all lowercase 'a-z' characters and replace them with an uppercase character. //echo -ag $regsubex(abcdefg,/([a-z])/g,$upper(\1)) </pre>