Created
March 2, 2018 00:08
-
-
Save NeuroWinter/b6bb5e402d696cf4a365121235fafe51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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