Return to Snippet

Revision: 47621
at July 15, 2011 12:58 by StrawMan


Updated Code
//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, '');
}

Revision: 47620
at June 11, 2011 13:16 by StrawMan


Initial Code
//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, '');
}

Initial URL

                                

Initial Description

                                

Initial Title
String Manipulation - Regex Collection

Initial Tags

                                

Initial Language
JavaScript