scan
scans a string for regular expression matches and extracts groups
(string subject, string pattern) -> list
Returns a list of matches and captured groups for each successive match of regular expression pattern
in subject
Each match generates a list with the following properties: Index 0 contains the matched input string, and subsequent indexes contain any matched capturing groups. Group indexes correspond to the sequence of opening group parentheses of capturing groups in the pattern. If a group is optional, and is not matched by the input string, its value in the list is nil
If a capturing group is inside a quantifier, only the last matched string is captured.
Returns an empty list in case there are no matches of pattern
in subject
Returns nil
if any argument is nil
Parameters
Name | Type | Description |
---|---|---|
subject |
string | The string to match |
pattern |
string | The regular expression pattern to match |