$regmlex » History » Version 9
Per Amundsen, 02/23/2023 07:23 PM
| 1 | 1 | Per Amundsen | _Added in 2.4_ |
|---|---|---|---|
| 2 | |||
| 3 | 7 | Per Amundsen | *$regmlex([name], M, N, [&binvar])* |
| 4 | 1 | Per Amundsen | |
| 5 | Returns the Nth [[Scripting_Regex|regular expression]] capture group from the Mth match from [[$regex]], [[$regsub]], [[$regsubex]] or from an [[Scripting_Events|event]]. |
||
| 6 | |||
| 7 | 6 | Per Amundsen | _See also [[$regsubex]], [[$regsub]], [[$regex]], [[$regml]], [[$regerrstr]]._ |
| 8 | 1 | Per Amundsen | |
| 9 | *Parameters* |
||
| 10 | |||
| 11 | 9 | Per Amundsen | table(ktable). |
| 12 | |*Parameter*|*Description*| |
||
| 13 | | [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) | |
||
| 14 | | M | If M = 0, number of matches, otherwise the Mth match. | |
||
| 15 | | N | The Nth group. | |
||
| 16 | | [&binvar] | Adds the match to the specified &binvar instead. (changes return value to number of bytes added) | |
||
| 17 | 1 | Per Amundsen | |
| 18 | 8 | Per Amundsen | *Properties* |
| 19 | 1 | Per Amundsen | |
| 20 | 9 | Per Amundsen | table(ktable). |
| 21 | |*Property*|*Description*| |
||
| 22 | | .pos | Returns the match position in the text. | |
||
| 23 | | .group | Returns the group position (includes empty groups). | |
||
| 24 | 1 | Per Amundsen | |
| 25 | *Example* |
||
| 26 | |||
| 27 | <pre> |
||
| 28 | ; Search the text for the pattern 'abcdef' and print the result. |
||
| 29 | 2 | Per Amundsen | //echo -ag Number of matches: $regex(abcdef,/([a-z])([a-z])/g) - $regmlex(1,1) $regmlex(1,2) $regmlex(2,1) $regmlex(2,2) |
| 30 | 1 | Per Amundsen | </pre> |