$regbr » History » Version 4
  Per Amundsen, 02/23/2023 07:22 PM 
  
| 1 | 1 | Per Amundsen | _Added in 1.9.6_ | 
|---|---|---|---|
| 2 | |||
| 3 | 3 | Per Amundsen | *$regbr([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 | _Same as [[$regml]]._ | ||
| 8 | |||
| 9 | *Parameters* | ||
| 10 | |||
| 11 | 4 | 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 | | N | If N = 0, number of matches, otherwise the Nth match. | | ||
| 15 | | [&binvar] | *TODO* | | ||
| 16 | 1 | Per Amundsen | |
| 17 | *Properties* | ||
| 18 | |||
| 19 | 4 | Per Amundsen | table(ktable). | 
| 20 | |*Property*|*Description*| | ||
| 21 | | .pos | Returns the match position in the text. | | ||
| 22 | | .group | Returns the group position (includes empty groups). | | ||
| 23 | 2 | Per Amundsen | |
| 24 | 1 | Per Amundsen | *Example* | 
| 25 | |||
| 26 | <pre> | ||
| 27 | ; Search the text for the pattern '(hello)' and print the result. | ||
| 28 | //echo -ag Number of matches: $regex(Hello World, /(Hello)/) match 1 is: $regbr(1) | ||
| 29 | |||
| 30 | ; Prefix an event with '$' allows the use of a regular expression in the 'matchtext' field which will fill $regbr with the result. | ||
| 31 | on $*:TEXT:/Hello/g:*:echo -ag found $regbr(0) matches, first match was $regbr(1) | ||
| 32 | </pre> |