/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Usage var you = 'hello you guys'.between('hello ',' guys'); * you = 'you'; */ String.prototype.between = function(prefix, suffix) { s = this; var i = s.indexOf(prefix); if (i >= 0) { s = s.substring(i + prefix.length); } else { return ''; } if (suffix) { i = s.indexOf(suffix); if (i >= 0) { s = s.substring(0, i); } else { return ''; } } return s; }
URL: http://userscripts.org/scripts/review/35396
Comments
