
Using this internally, exec() can be used to iterate over multiple matches in a string of text (with capture groups), as opposed to getting just the matching strings with (). They store a lastIndex from the previous match. JavaScript RegExp objects are stateful when they have the global or sticky flags set (e.g. If the regular expression doesn't contain any named capturing groups, groups is undefined. The keys are the names of the capturing groups, and each value is a two-element array, with the first number being the start index, and the second number being the end index of the capturing group. The indices array additionally has a groups property, which holds a null-prototype object of all named capturing groups. Each entry itself is a two-element array, where the first number represents the match's start index, and the second number, its end index. In other words, the first indices entry represents the entire match, the second indices entry represents the first capturing group, etc.

The index of each element in this array corresponds to the index of the respective substring match in the array returned by exec(). It is an array where each entry represents the bounds of a substring match. This property is only present when the d flag is set. See capturing groups for more information. groupsĪ null-prototype object of named capturing groups, whose keys are the names, and values are the capturing groups, or undefined if no named capturing groups were defined. The original string that was matched against. The 0-based index of the match in the string. The array also has the following additional properties: index The returned array has the matched text as the first item, and then one item for each capturing group of the matched text. If the match succeeds, the exec() method returns an array and updates the lastIndex property of the regular expression object.


If the match fails, the exec() method returns null, and sets the regex's lastIndex to 0. Deprecated Object.prototype._lookupSetter_().Deprecated Object.prototype._lookupGetter_().Deprecated Object.prototype._defineSetter_().Deprecated Object.prototype._defineGetter_().
