Sticky flag "y", searching at position

Cờ Y là Tìm Kiếm Vị Trí

//1. tìm vị trí varname
var str = 'let varName = "value"';

var regexp = /\w+/g;

// start the search from position 3
regexp.lastIndex = 3;

var word = regexp.exec(str);
// found the match at position 4
alert(word[0]); // varName
alert(word.index); // 4

//2. tìm với cờ y

var str = 'let varName = "value"';

var regexp = /\w+/y;

regexp.lastIndex = 3;
alert( regexp.exec(str) ); // null (there's a space at position 3, not a word)

regexp.lastIndex = 4;
alert( regexp.exec(str) ); // varName (word at position 4)