I have been stuck on this silly issue for hours now. I know it seems stupid but I really don't know what I am missing. Any help would be appreciated.
Here's my issue:
var objReg = /touch/g;
var str = "abc touch def touch";
var arr = objReg.exec(str);
Here I expect the array arr
to contain 2 elements but it only contains the 1st element even though I made sure to put the g
modifier.
Can anyone guide me what is to be done here?
Debug: As shown in the image below, the array has just 1 element(index=0)