Having the following js code:
const text = '>>>>\n>>>>\n';
const regex = /^>.*$/ig;
let lines = text.split(/\r?\n/);
let i = lines.length - 1;
if (lines[i] === '') {
i -= 1;
}
console.log(regex.test(lines[i]));
console.log(regex.test(lines[i]));
console.log(regex.test(lines[i]));
console.log(regex.test(lines[i]));
It outputs:
true
false
true
false
But I expect all outputs to be true
. Is there anything I misunderstand?