Код ошибки: попытка вызвать нулевое значение < local 'cb' >

exec возвращает объект со свойством index:

var match = /bar/.exec("foobar");
if (match) {
    console.log("match found at " + match.index);
}

И для нескольких совпадений:

var re = /bar/g,
    str = "foobarfoobar";
while ((match = re.exec(str)) != null) {
    console.log("match found at " + match.index);
}

0
задан Egor Skriptunoff 18 January 2019 в 20:36
поделиться