Regex capture behaviour has been changed

Published: | Categories: JavaScript


In regular expressions, including String.replace, the matched text for a capturing group will be undefined instead of an empty string when the quantifiers prevented the group from being consulted (see also this sample code). Note that, for backward compatibility, RegExp.$N will still return an empty string rather than undefined (bug 1053944).

A performance regression of regular expressions introduced with Firefox 32 has also been fixed with Firefox 34. This issue might have lead to an “unresponsive script” dialog on Firefox 32 and 33 when using String.match, for example.