zikaari / regexly

WYSIWYG Regex playground for those who JavaScript
https://regexly.js.org
MIT License
165 stars 3 forks source link

Incorrect output when `y` flag used #2

Closed simevidas closed 5 years ago

simevidas commented 7 years ago

With this input:

regexp = /foo/y
string = foofoo

the regexp.exec(string) value is null, but the value should be the same as when the g flag is used (at least in this case, IIUC; try in the browser’s console).

foo

zikaari commented 7 years ago

Thanks for the heads up. The issue is being caused by use of same RegExp object (reference) for all the operations. Given the same variables, if string.match(regexp) is called before exec, the value is null.

So the fix would be to "clone" the regex object instead of sharing between those calls. Right now I'm in the process of migrating Regexly to dockerized setup on AWS (v0.2.0 will have server backed permalinks) so this fix will also land in v0.2.0. It's taking longer than usual because of my lack of experience with docker and aws.