Sunday 2 June 2019

javascript - Removing last comma

I read content from a file and then write it another file after editing . While editing , for each read line i put a comma at the end of line and then write it to the file. For the last read line i do not want to write a comma. How should i do it.?



 while(!inputFile.AtEndOfStream){
var readLine = inputFile.ReadLine();
var omitChars = new RegExp("#define").test(readLine);
if(omitChars==1){
var stringReadPosition = readLine.substr(8);

var finalString = stringReadPosition.replace(/\s+/g, ': ');
asd = outputFile.Write(finalString.replace(/^(_)/, "") + ",\r\n");
}
}
outputFile.Write("};\r\n");
inputFile.Close();
outputFile.Close();
}

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...