getGroupCount: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{MacroFunction
{{MacroFunction
|name=getGroupCount
|name=getGroupCount
|version=1.3b48
|description=Returns the number of capture groups for the match performed by [[strfind|strfind()]].
|description=Returns the number of capture groups for the match performed by [[strfind|strfind()]].


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: text = getGroupCount(id)]
[h: text = getGroupCount(id)]
</source>
</syntaxhighlight>
id is the id returned by [[strfind|strfind()]]
id is the id returned by [[strfind|strfind()]]
|example=
|example=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: id = strfind("this is a test", "(\\S+)\\s(\\S+)\\s*")]
[h: id = strfind("this is a test", "(\\S+)\\s(\\S+)\\s*")]
[r: getGroupCount(id)]
[r: getGroupCount(id)]
</source>
</syntaxhighlight>
Returns 2.
Returns 2.
}}
}}
[[Category:String Function]]
[[Category:String Function]]

Latest revision as of 18:35, 14 March 2023

getGroupCount() Function

Introduced in version 1.3b48
Returns the number of capture groups for the match performed by strfind().

Usage

[h: text = getGroupCount(id)]

id is the id returned by strfind()

Example

[h: id = strfind("this is a test", "(\\S+)\\s(\\S+)\\s*")]
[r: getGroupCount(id)]
Returns 2.