MATCH(<subject>,<pattern>,[&target],[group],[default])

Category
Calculations
Added in
v0.8.6

Runs a regular expression match on the <subject> and puts the result in <&target>.

Returns the matched groups as an array.

Alternative Syntax;

MATCH(<subject>,<pattern>,{&target1,&target2,&target3})
MATCH(<subject>,<pattern>,&target[])

Example

&input = "Hello World!!"
&regex = "(Hello) (World)"

MATCH(%&input%,%&regex%,&match)
// &match now contains the whole match "Hello World"

MATCH(%&input%,%&regex%,&match,2)
// &match now contains only the second group "World"

MATCH("no match",%&regex%,&match,1,"default")
// &match now contains the default value "default", since the regex couldn't match the input

MATCH(%&input%,%&regex%,{&hello,&world})
// &hello and &world now contain the first and second group

&groups[] = MATCH(%&input%,%&regex%)
// &groups[] now contains the whole match and the two groups

See also

Changelog