What's wrong with this JavaScript RegExp stateful?

What's wrong with this JavaScript RegExp stateful with global flag. The JavaScript code reuses a regex with g flag. In JavaScript lastIndex persists and the next match starts from wrong position.

#whatswrongwiththisjavascriptcode #javascriptbug #javascriptproductionbug #javascriptdebugging #javascriptbackend #javascriptcodereview #javascriptsecurity #javascriptperformance #javascriptreliability #...

https://www.youtube.com/watch?v=Fc6zoznH4uY

Whats wrong with this JavaScript RegExp stateful? #javascriptperformance

YouTube