$regml » History » Version 16
Per Amundsen, 09/20/2020 03:51 AM
| 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 | [name] - A named [[Scripting_Regex|regular expression]], if not defined result from the last [[Scripting_Regex|regular expression]] is returned. (optional) |
||
| 14 | N - If N = 0, number of matches, otherwise the Nth match. |
||
| 15 | 16 | Per Amundsen | [&binvar] - Adds the match to the specified &binvar instead. (changes return value to number of bytes added) |
| 16 | 1 | Per Amundsen | |
| 17 | 5 | Per Amundsen | *Properties* |
| 18 | |||
| 19 | .pos - Returns the match position in the text. |
||
| 20 | .group - Returns the group position (includes empty groups). |
||
| 21 | 12 | Per Amundsen | .full - Returns the full match. *(AdiIRC only)* |
| 22 | 5 | Per Amundsen | |
| 23 | 1 | Per Amundsen | *Example* |
| 24 | |||
| 25 | <pre> |
||
| 26 | ; Search the text for the pattern '(hello)' and print the result. |
||
| 27 | //echo -ag Number of matches: $regex(Hello World, /(Hello)/) match 1 is: $regml(1) |
||
| 28 | |||
| 29 | 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. |
| 30 | 1 | Per Amundsen | on $*:TEXT:/Hello/g:*:echo -ag found $regml(0) matches, first match was $regml(1) |
| 31 | </pre> |