I am boggled by regex I think I\'m dyslexic when it comes to these horrible bits of code.. anyway, there must be an easier way to do this- (ie. list a set of replace instanc
You can define either a generic function, which would make sense if you can reuse it in more parts of your code, thus making it DRY. If you don't have reason to define a generic one, I would compress only the part which cleans sequences and leave the other replaces as they are.
function clean(string) {
string = string.replace(/\@~rb~@|\@~lb~@|\@~qu~@|\@~cn~@|\@-cm-@/g, '')
.replace(/}/g, '@~rb~@').replace(/{/g, '@~lb~@')
.replace(/\"/g, '@~qu~@').replace(/\:/g, '@~cn~@')
.replace(/\,/g, '@-cm-@');
return string;
}
But be careful, the order of the replacements were changed it in this code.. although it seems they might not affect the result.