JSFiddle - React, Tailwind, and code Playground
JavaScript
var l = /[a-z]/g;
// will match "a" and return true
console.log(l.test("a"));
// lastIndex is now 1
console.log(l.lastIndex);
// starts searching from position 1, and doesn't match anything
// so returns false
console.log(l.test("x---"));
// wraps around lastIndex is now 0 again, should behave normally now
console.log(l.lastIndex);