Remove lastIndex assignment to regex after it's already been used.