getGroupEnd

From RPTools Wiki
Revision as of 18:17, 14 March 2023 by Taustin (talk | contribs) (Text replacement - "source>" to "syntaxhighlight>")
Jump to navigation Jump to search

getGroupEnd() Function

Introduced in version 1.3b48
Returns the end index of the specified capture group for the specified match that was found using strfind()

Usage

<source lang="mtmacro" line> getGroupEnd(id, match, group) </syntaxhighlight> Where

  • id is the id returned by strfind()
  • match is the number of the match found by strfind()
  • group is the number of the capture group found by strfind()

Example

<source lang="mtmacro" line>

[h: id = strfind("this is a test", "(\\S+)\\s(\\S+)\\s*")] match 1, group 1 end = [getGroupEnd(id, 1, 1)]
match 1, group 2 end = [getGroupEnd(id, 1, 2)]
match 2, group 1 end = [getGroupEnd(id, 2, 1)]
match 2, group 2 end = [getGroupEnd(id, 2, 2)]
</syntaxhighlight> Returns

match 1, group 1 end = 4 
match 1, group 2 end = 7 
match 2, group 1 end = 9 
match 2, group 2 end = 14