3 ms·
Is there a way to find all occurrences/matches of a regex that doesn't have the 'g' modifier? Just tried `string.match` and `regex.exec` and could only get the
by a13n 7y ago
Is there a way to find all occurrences/matches of a regex that doesn't have the 'g' modifier?
Just tried `string.match` and `regex.exec` and could only get the first match.
- zamadatix 7y agoI don't think so without modifying the string or regex each iteration. You'd have to do something like let flagified = new RegExp(original.source, original.flags + "g") or modify the regex standards as part of the proposal.
- chipperyman573 7y agoI tried to do this a while ago for a side project. There might be a really obscure way (and of course you can always write your own function), but I wasn't able to find anything built in.