Skip to content

Instantly share code, notes, and snippets.

@bjarneo
Created February 4, 2013 14:23
Show Gist options
  • Save bjarneo/4706975 to your computer and use it in GitHub Desktop.
Save bjarneo/4706975 to your computer and use it in GitHub Desktop.
Javascript Snippets

Javascript Snippets

Remove newline and whitespace from string. Todo: (merge regX)

function removeWhiteSpaceAndNewLine(myString) {
    var regX = /\n/gi;
    var regXs = /(\s)/gi;
    s = new String(myString);
    s = s.replace(regX, "");
    s = s.replace(regXs, "");

    return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment