Project

General

Profile

$regsubex » History » Version 3

Per Amundsen, 05/07/2017 11:15 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
*Parameters*
10
11
[name] - Name of the search, which can later be referenced using [[$regml]]. (optional)
12
text - The text to search.
13
re - The [[Scripting_Regex|regular expression]] to perform.
14
subtext - Subtext to replace with.
15 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)
16 1 Per Amundsen
17
*Subtext*
18
19
The subtext evaluates identifiers before performing the substitution and special markers can be used to reference various parts of the result.
20
21
\0 - Returns the number of matches.
22
\n - Returns the current match number.
23
\t - Returns the current match text (same as [[$regml]](\n)).
24
\a - Returns all matching items.
25
\A - Returns a non-spaced version of \a.
26
\1 \2 \N ... - Returns the Nth back-reference made for a given match 
27
28
*Example*
29
30
<pre>
31
; Find all lowercase 'a-z' characters and replace them with an uppercase character.
32
//echo -ag $regsubex(abcdefg,/([a-z])/g,$upper(\1))
33
</pre>