-
-
Save brianloveswords/0e85c8eca3f73853408f69702ab4b3eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let re = /a/g | |
re.test('ab') // true | |
re.test('ab') // this will fail! re.lastIndex === 1, so it starts searching at 'b' | |
re.test('ab') // this will pass! since it failed, re.lastIndex is reset to 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment