/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Remove every second comma only and replace with spaces and double colon. function remComma(str) { return str = str.replace(/(,[^,]*),/g, '$1 :: '); } //Remove all commas outside of html markup only. function remAllComma(str) { return str = str.replace(/,(?!([^<]+)?>)/g, ''); } //Remove all commas, everywhere. function remTotalComma(str) { return str = str.replace(/,/g, ''); } //Discard all square brackets from string. function remSquareBrackets(str) { return str = str.replace(/\[|\]/g, ''); }