Ignoring the g
flag, are exec
and match
the same thing but in reverse order — i.e., inverses?
const str = "Hello";
const reg = /he/i;
console.log(reg.exec(str));
console.log(str.match(reg));
console.log(JSON.stringify(reg.exec(str)) === JSON.stringify(str.match(reg)));
Or, minus ordering and g
, are they ever used in different ways and/or have different characteristics?