Skip to content

Instantly share code, notes, and snippets.

@mly520
Last active September 10, 2018 00:17
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 mly520/768ff6bbb5a11960a3f897ac5c20d5b7 to your computer and use it in GitHub Desktop.
Save mly520/768ff6bbb5a11960a3f897ac5c20d5b7 to your computer and use it in GitHub Desktop.
javascript 関数
String.prototype.before = function(word, include){
var idx = this.indexOf(word)
var l = include ? word.length : 0
return idx >= 0 ?
this.substr(0, idx + l) :
""
}
String.prototype.after = function(word, include){
var idx = this.indexOf(word)
var l = include ? 0 : word.length
return idx >= 0 ?
this.substr(idx + l) :
""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment