I want to capture thing in nothing globally and case insensitively.
For some reason this doesn’t work:
"Nothing thing nothing".match(/no(thing)/gi);
The captured array is Nothing,nothing instead of thing,thing.
I thought parentheses delimit the matching pattern? What am I doing wrong?
(yes, I know this will also match in nothingness)
If you use the global flag, the match method will return all overall matches. This is the equivalent of the first element of every match array you would get without global.
To get all groups from each match, loop:
This will give you
["Nothing", "thing"]and["nothing", "thing"].