$regml » History » Version 17
Per Amundsen, 02/23/2023 07:20 PM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | 13 | Per Amundsen | *$regml([name], N, [&binvar])* |
4 | 1 | Per Amundsen | |
5 | Returns the Nth [[Scripting_Regex|regular expression]] match from [[$regex]], [[$regsub]], [[$regsubex]] or from an [[Scripting_Events|event]]. |
||
6 | |||
7 | 15 | Per Amundsen | _Same as [[$regbr]]._ |
8 | 8 | Per Amundsen | |
9 | 11 | Per Amundsen | _See also [[$regsubex]], [[$regsub]], [[$regex]], [[$regmlex]], [[$regerrstr]]._ |
10 | 4 | Per Amundsen | |
11 | 1 | Per Amundsen | *Parameters* |
12 | |||
13 | 17 | Per Amundsen | table(ktable). |
14 | |*Parameter*|*Description*| |
||
15 | | [name] | A named [[Scripting_Regex<notextile>|</notextile>regular expression]], if not defined result from the last [[Scripting_Regex<notextile>|</notextile>regular expression]] is returned. (optional) | |
||
16 | | N | If N = 0, number of matches, otherwise the Nth match. | |
||
17 | | [&binvar] | Adds the match to the specified &binvar instead. (changes return value to number of bytes added) | |
||
18 | 1 | Per Amundsen | |
19 | *Properties* |
||
20 | |||
21 | 17 | Per Amundsen | table(ktable). |
22 | |*Property*|*Description*| |
||
23 | | .pos | Returns the match position in the text. | |
||
24 | | .group | Returns the group position (includes empty groups). | |
||
25 | | .full | Returns the full match. *(AdiIRC only)* | |
||
26 | 5 | Per Amundsen | |
27 | 1 | Per Amundsen | *Example* |
28 | |||
29 | <pre> |
||
30 | ; Search the text for the pattern '(hello)' and print the result. |
||
31 | //echo -ag Number of matches: $regex(Hello World, /(Hello)/) match 1 is: $regml(1) |
||
32 | |||
33 | 3 | Per Amundsen | ; Prefix an event with '$' allows the use of a regular expression in the 'matchtext' field which will fill $regml with the result. |
34 | 1 | Per Amundsen | on $*:TEXT:/Hello/g:*:echo -ag found $regml(0) matches, first match was $regml(1) |
35 | </pre> |