Is there any better solution to this here? I try to avoid the assignment inside while but still be able to loop through the matches and use the captured groups.
var match = "";
var CSS_URL_PATTERN = /url\s*\(\s*["|']?(.*?)\s*["|']?\)\s*/gm
while ((match = CSS_URL_PATTERN.exec(someBigCSSString)) !== null) {
// Do stuff here per match…
}
I added a bit more context to this question, also a RegEx example.
match. It will return an array which you can loop. You way you designed it now will be an endless loop.gflag. In this case, it should be assigned outside loop.