Skip to content

Instantly share code, notes, and snippets.

@Boztown
Created May 1, 2012 19:15
Show Gist options
  • Save Boztown/2570637 to your computer and use it in GitHub Desktop.
Save Boztown/2570637 to your computer and use it in GitHub Desktop.
Javascript: Trim First/Last Characters in String
// Remove last four characters
var myString = "abcdefg";
var newString = myString.substr(0, myString.length-4);
// Remove first two characters
var myString = "abcdefg";
var newString = myString_2.substr(2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment