Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeuroWinter/b6bb5e402d696cf4a365121235fafe51 to your computer and use it in GitHub Desktop.
Save NeuroWinter/b6bb5e402d696cf4a365121235fafe51 to your computer and use it in GitHub Desktop.
function Parse(str){
return str.split("\n").map((e, i, arr) => {
console.log(`${i} of ${arr.length}!`); //Like this
if(e.indexOf(':') > -1){
let end = e.split(':').pop();
let first = end.indexOf(`"`);
let last = end.lastIndexOf(`"`);
if(first === last || first < 0) return e.replace(new RegExp('\\\\', 'g') , "\\\\");
return e.split(':')[0] + `: "${end.substring(++first, last).replace(new RegExp(`"`, 'g'), `'`).replace(new RegExp('\\\\', 'g') , "\\\\")}"`;
} else return e.replace(new RegExp('\\\\', 'g') , "\\\\");;
}).join('\n');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment