$regsubex » History » Version 1
Per Amundsen, 08/13/2015 10:52 AM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | $regsubex([name], text, re, subtext) |
||
4 | |||
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 | |||
16 | *Subtext* |
||
17 | |||
18 | The subtext evaluates identifiers before performing the substitution and special markers can be used to reference various parts of the result. |
||
19 | |||
20 | \0 - Returns the number of matches. |
||
21 | \n - Returns the current match number. |
||
22 | \t - Returns the current match text (same as [[$regml]](\n)). |
||
23 | \a - Returns all matching items. |
||
24 | \A - Returns a non-spaced version of \a. |
||
25 | \1 \2 \N ... - Returns the Nth back-reference made for a given match |
||
26 | |||
27 | *Example* |
||
28 | |||
29 | <pre> |
||
30 | ; Find all lowercase 'a-z' characters and replace them with an uppercase character. |
||
31 | //echo -ag $regsubex(abcdefg,/([a-z])/g,$upper(\1)) |
||
32 | </pre> |