I don't understand why RegExp.prototype.exec() is returning null when the file I do regex on is big

Viewed 40

So I have been trying to figure out why the code is not working when the data variable gets content from a big file to do the regex on. also here is link to the file that I'm doing regex on https://easyupload.io/8cbsou

const fs = require("fs");

function getFilecontent(fs, filename)
{
    return fs.readFileSync(filename, {encoding:'utf8', flag:'r'});
}

async function test(re, data) 
{
    let promise = new Promise(async (res, rej) => {
        let array1;
        while((array1 = await re.exec(data)) !== null)
            console.log(array1[0]);

        res("cool");
    });
    promise.then(results => {console.log(results)});
}

let data = getFilecontent(fs, 'lol').toString();
test(/"Market":/g, data);
0 Answers
Related