Skip to content

Instantly share code, notes, and snippets.

@krizpoon
Last active August 29, 2015 14:07
Show Gist options
  • Save krizpoon/0b0800c35d7b86abafd8 to your computer and use it in GitHub Desktop.
Save krizpoon/0b0800c35d7b86abafd8 to your computer and use it in GitHub Desktop.
Javascript String Utilities
String.prototype.getFileExtension = function()
{
var ret = (/[.]/.exec(this)) ? /[^.]+$/.exec(this) : undefined;
if (ret && ret.length) ret = ret[0];
return ret;
}
if (typeof String.prototype.startsWith != 'function')
{
String.prototype.startsWith = function (str)
{
return this.indexOf(str) === 0;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment