0

Try to use node read a file and use regex to do something

const langFiles = 'test.php';
const fs = require('fs');

    const data = fs.readFileSync(langFiles, 'utf8');
    var pat = "\".*\.\w+\"" ;
    var rex = new RegExp( pat, "gim" ) ;
    var rep = "$1" ;
    var res = data.replace( rex, rep ) ;
    console.log( res ) ;

My regex already correct but my console result show the entire file, it seems it didn't execute the regex? test.php look like this https://pastebin.com/YFUD6AiE

Jessie Anderson
  • 319
  • 6
  • 13

0 Answers0