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