Last active
March 16, 2018 01:53
-
-
Save a1exlism/cd1a7b6183c2837001f0b6d0bcce1197 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
The expression will only match from its `lastIndex` position and `ignores` the global (g) flag if set. | |
let reg = /^foo/y; | |
let reg2 = new RegExp(reg.source, 'my'); | |
reg.test('foo'); // false | |
reg.lastIndex = 1; | |
reg.test('\nfoo'); // false | |
reg2.test('foo'); // false; | |
reg2.lastIndex = 1; | |
reg2.test('\nfoo'); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment