Gets all of the matches found when matching a regular expression against a string.

This function is valid in v2.0.0 to v2.10.2. This function has been downloaded 11 times.


{string} str
String against which the regular expression should be matched.
{RegExp} rgx
Regular expression to match against str.
{function(Array,number)=} opt_fnMapper Optional
If specified the return value of this function will always be appended to the array which will be returned by matchAll() unless undefined is the return value. The 1st argument passed will be an array representing the matches array that was found. The 2nd argument passed will be the amount of times this mapper has been called.


If rgx matched a substring in str at least once and opt_fnMapper wasn't used, an array of all of the matches will be returned. Each match will at least have match[0], match.index (the starting index of the found match within str), match.source (rgx) and match.input (str). If capture groups were specified in rgx, each will be found in its corresponding index starting with match[1]. If no matches were found, null is returned.

Required Function

This function requires the following function which is included automatically:

  • slice()
    Slice does not modify the original array, but instead returns a shallow copy of elements from the original array.