gricha2380 / regex

https://gricha2380.github.io/regex/demo
0 stars 0 forks source link

.exec() does not match with ? qualtifier #36

Open gricha2380 opened 6 years ago

gricha2380 commented 6 years ago

I'm still unable to get .exec() to match with the ? quantifier. If the same quantifier is run in a JS regex tester the the match would work but displays a warning. This is apparently a known limitation of .exec(). The challenge is documented here.

Older versions of matchEnemies used .match() which worked as expected. Here's the final commit of matchEnemy() which used the old method.

exec() docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec

match() docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match


Related Issue: https://github.com/gricha2380/regex/issues/33

Related Stackoverflow reference: https://stackoverflow.com/questions/2295657/return-positions-of-a-regex-match-in-javascript