Methods of RegExp and String - JavaScript
javascript.info › regexp-methodsJun 13, 2021 · The regexp.exec (str) method returns a match for regexp in the string str. Unlike previous methods, it’s called on a regexp, not on a string. It behaves differently depending on whether the regexp has flag g. If there’s no g, then regexp.exec (str) returns the first match exactly as str.match (regexp). This behavior doesn’t bring anything new.