Version: v0.6.0 - Beta.  We welcome contributors & feedback.  THanks!

String.matchAll

matchAll($regexPattern)

Description

Apply a regex pattern and return all matches.

Returns false if there are no matches.

If there is a match, it returns a List of Lists where each top-level item is a match (per String.match). Each sub-item is a list of captures (item 0 being the entire value).

Call the flags method on the regex string to add modifier flags.

'<b><span>Home</span></b>'.matchAll(r'<(\w+)>');
// [
//    [
//        '<b>',  // entire value
//        'b'     // captured in parens ($1)
//    ],
//    [
//        '<span>',
//        'span'
//    ]
// ]

'abc def xyz'.matchAll(r'\d+');
//= false

See Also