-
-
Save mly520/768ff6bbb5a11960a3f897ac5c20d5b7 to your computer and use it in GitHub Desktop.
javascript 関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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