Skip to content

Instantly share code, notes, and snippets.

@rreimi
Created February 20, 2016 01:18
Show Gist options
  • Save rreimi/dda7cea58648277c07cb to your computer and use it in GitHub Desktop.
Save rreimi/dda7cea58648277c07cb to your computer and use it in GitHub Desktop.
Javascript String util functions
//EndsWith
String.prototype.endsWith = function(str)
{return (this.match(str+"$")==str)}
//StartsWith
String.prototype.startsWith = function(str)
{return (this.match("^"+str)==str)}
//Trim
String.prototype.trim = function(){return
(this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""))}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment