getGroupStart: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function getGroupEnd== {{ProposedChange}} Returns the start index of the specified capture group for the specified match that was found using strfind() ==...)
 
No edit summary
Line 7: Line 7:
===Usage===
===Usage===
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: text = getGroup(id, match, group)]
[h: text = getGroupStart(id, match, group)]
</source>
</source>
Where  
Where  

Revision as of 21:03, 1 December 2008

Function getGroupEnd

 Note: This refers to a proposed change that has not been implemented in the main code base yet.

Returns the start index of the specified capture group for the specified match that was found using strfind()


Usage

[h: text = getGroupStart(id, match, group)]

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()

Examples

[h: id = strfind("this is a test", "(\\S+)\\s(\\S+)\\s*")]
match 1, group 1 start = [getGroupStart(id, 1, 1)]<br>
match 1, group 2 start = [getGroupStart(id, 1, 2)]<br>
match 2, group 1 start = [getGroupStart(id, 2, 1)]<br>
match 2, group 2 start = [getGroupStart(id, 2, 2)]<br>

Returns

match 1, group 1 start = 0 
match 1, group 2 start = 5 
match 2, group 1 start = 8 
match 2, group 2 start = 10