Skip to content

Instantly share code, notes, and snippets.

@dustinpoissant
Created December 1, 2017 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinpoissant/6f535d108a16c92f1431fdfd51a8ba16 to your computer and use it in GitHub Desktop.
Save dustinpoissant/6f535d108a16c92f1431fdfd51a8ba16 to your computer and use it in GitHub Desktop.
Extract a substring from a string between two substrings.
String.prototype.extract = function(start, finish){
var s = this.indexOf(start);
if(s == -1) return "";
var e = this.indexOf(finish, s + start.length);
if(e == -1) return "";
return this.substring(s + start.length, e);
}
String.prototype.extract=function(t,n){var r=this.indexOf(t);if(-1==r)return"";var i=this.indexOf(n,r+t.length);return-1==i?"":this.substring(r+t.length,i)};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment