How to retain text between regex matches in Javascript? : I would like to extract some tags from string and perform some operations according to them, but the remaining string should retain with stripped tags and go for further processing.

Is it possible to do this in one run?

For example, if I have a code, which is taking tags:

                            while (match = regex.exec(str)) {
                                result.push( match[1] );
                            }

can I take what between matches simultaneously?