In JavaScript, regular expression objects have state. This matters when the flag ("global") is applied to them, and sometimes applies in odd ways. This state is the index where the match last occurred, which is the regex's property. When you call or on the same regex object again, it picks up from where it left off.
Chopper Lee
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with Chopper
Contact Chopper, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack