Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- split("hey ho what's up", ["-", "'", "."])
- -> returns ["hey ho what", "s up"]
- split("hey ho what's up", ["-", "'", "."], true)
- -> returns ["hey ho what", "'s up"]
- */
- function split(inp, identifiers, withAppend) {
- if (typeof(withAppend) === 'undefined') withAppend = false;
- for (var i in identifiers) {
- var index = inp.indexOf(identifiers[i]);
- if (index > -1)
- return [inp.substr(0, index), inp.substr(withAppend ? index : index + 1, inp.length)];
- }
- return [inp];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement