MoneyWorks Manual
Regex_GetMatches (string, regex)
Result Type: Array
Definition: Returns an array of tokens that match the parenthesised subexpressions in the regular expression
Examples:
on Parse_File(f) foreach line in textfile f let a = Regex_GetMatches(line, "([0-9]+)\t([^\t]*).*\t([^\t]*)") // get first, second, and last tab-delimited fields from line, only when first field is numeric if CountElements(a) // a[0] is the full match syslog(a[1] + " : " + a[2] + " : " + a[3]) endif endfor end
parsing this file:
heading ----------- 1 foo bar baz this 2 foo bar baz is 3 foo bar baz the ignore this line 4 foo bar last 5 foo token
outputs
1 : foo : this 2 : foo : is 3 : foo : the 4 : foo : last 5 : foo : token
Availability: In MWScript in v9.1 and later.
See Also:
Dice: Get a subcomponent of a delimited tabular string
Head: Get some elements from the start of a delimited string
Left: Get characters from the start of a string
Mid: Get characters from the middle of a string
Regex_Match: Test whether a string matches a regular expression
Regex_Replace: Replace text in a string using a regular expression
Regex_Search: Find the first match of a regular expression in a string
Regex_SearchStr: Find the first match of a regular expression in a string and return the matching string
RemoveLeading: Remove characters from the start of a string
RemoveTrailing: Remove characters from the end of a string
Replace: Replace matching text in a string with new text
Right: Get characters from the end of a string
Slice: Get a component of a delimited string
Tail: Get some elements from the end of a delimited string
Trim: Remove whitespace from beginning and end of a string