try see compare understand learn JavaScript Regular Expressions

RegExp panel with /g or /y flag

This panel uses the exec() method of RegExp to generate the output. This happens when the g or y option is checked. The exec() method is driven by the lastIndex attribute.