Project

General

Profile

$regsubex » History » Version 6

Per Amundsen, 06/30/2021 01:24 PM

1 1 Per Amundsen
_Added in 1.9.0_
2
3 3 Per Amundsen
*$regsubex([name], text, re, subtext, [%var|&binvar])*
4 1 Per Amundsen
5
Performs a regular [[Scripting_Regex|regular expression]] and then performs a substitution using subtext.
6
7
Returns the substituted text.
8
9 5 Per Amundsen
_See also [[$regex]], [[$regsub]], [[$regml]], [[$regmlex]]. [[$regerrstr]]._
10 4 Per Amundsen
11 1 Per Amundsen
*Parameters*
12
13
[name] - Name of the search, which can later be referenced using [[$regml]]. (optional)
14
text - The text to search.
15
re - The [[Scripting_Regex|regular expression]] to perform.
16
subtext - Subtext to replace with.
17 3 Per Amundsen
[%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)
18 1 Per Amundsen
19
*Subtext*
20
21
The subtext evaluates identifiers before performing the substitution and special markers can be used to reference various parts of the result.
22
23
\0 - Returns the number of matches.
24
\n - Returns the current match number.
25
\t - Returns the current match text (same as [[$regml]](\n)).
26
\a - Returns all matching items.
27
\A - Returns a non-spaced version of \a.
28 6 Per Amundsen
\@ - Returns the total number of matches. *(AdiIRC only)*
29 1 Per Amundsen
\1 \2 \N ... - Returns the Nth back-reference made for a given match 
30
31
*Example*
32
33
<pre>
34
; Find all lowercase 'a-z' characters and replace them with an uppercase character.
35
//echo -ag $regsubex(abcdefg,/([a-z])/g,$upper(\1))
36
</pre>