JavaScript regular expressions: /g, /y, and .lastIndex

By Dr. Axel Rauschmayer

  • Update 2020-01-02: Restructured the content to make the introduction easier to understand.

In this blog post, we examine how the RegExp flags /g and /y work and how they depend on the RegExp property .lastIndex. We’ll also discover an interesting use case for .lastIndex that you may not have considered yet.

Source:: <a href=http://feedproxy.google.com/~r/2ality/~3/ackNn-VE6-Y/regexp-lastindex.html target="_blank" title="JavaScript regular expressions: /g, /y, and .lastIndex” >2ality