matches

Synopsis

@ matches("string", 'pattern', [n], [m])

returns the matches from "string" applied to the regex 'pattern'. if n is specified this will return the grouped matches of the n'th substring matching the specified pattern. if n and m are specified, all of the grouped matches of the n-m substrings will be returned.

Parameters

"string" - the string to match against the pattern and extract substrings from

'pattern' - a regular expression pattern that defines wether or not we have a match

Examples

# trim whitespace from start of a string $trimmed = matches("\t this is a test", '\s*(.*)')[0]; println($trimmed);

this is a test

See Also