$regsubex » History » Version 8
Per Amundsen, 02/23/2023 07:29 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 | 7 | Per Amundsen | table(ktable). |
| 14 | |*Parameter*|*Description*| |
||
| 15 | | [name] | Name of the search, which can later be referenced using [[$regml]]. (optional) | |
||
| 16 | | text | The text to search. | |
||
| 17 | | re | The [[Scripting_Regex<notextile>|</notextile>regular expression]] to perform. | |
||
| 18 | | subtext | Subtext to replace with. | |
||
| 19 | | [%var<notextile>|</notextile>&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) | |
||
| 20 | 1 | Per Amundsen | |
| 21 | *Subtext* |
||
| 22 | |||
| 23 | 7 | Per Amundsen | table(ktable). |
| 24 | |*Character*|*Description*| |
||
| 25 | | \0 | Returns the number of matches. | |
||
| 26 | | \n | Returns the current match number. | |
||
| 27 | | \t | Returns the current match text (same as [[$regml]](\n)). | |
||
| 28 | | \a | Returns all matching items. | |
||
| 29 | | \A | Returns a non-spaced version of \a. | |
||
| 30 | | \@ | Returns the total number of matches. *(AdiIRC only)* | |
||
| 31 | 1 | Per Amundsen | | \1 \2 \N ... | Returns the Nth back-reference made for a given match | |
| 32 | 7 | Per Amundsen | |
| 33 | 8 | Per Amundsen | The subtext evaluates identifiers before performing the substitution and special markers can be used to reference various parts of the result. |
| 34 | 1 | Per Amundsen | |
| 35 | *Example* |
||
| 36 | |||
| 37 | <pre> |
||
| 38 | ; Find all lowercase 'a-z' characters and replace them with an uppercase character. |
||
| 39 | //echo -ag $regsubex(abcdefg,/([a-z])/g,$upper(\1)) |
||
| 40 | </pre> |