From 5c2842e0d46a8cd6e3350e28f05abae44bb1960a Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 26 May 2012 15:05:11 +0200 Subject: [PATCH] add Ox.splice --- source/Ox/js/String.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/Ox/js/String.js b/source/Ox/js/String.js index 0f2be3d3..a57b5d8b 100644 --- a/source/Ox/js/String.js +++ b/source/Ox/js/String.js @@ -407,6 +407,17 @@ Ox.repeat = function(value, times) { return ret; }; +/*@ +Ox.splice [].splice for strings, returns a new string + > Ox.splice('12xxxxx89', 2, 5, 3, 4, 5, 6, 7) + '123456789' +@*/ +Ox.splice = function(string, index, remove) { + var array = string.split(''); + Array.prototype.splice.apply(array, Ox.slice(arguments, 1)); + return array.join(''); +}; + /*@ Ox.startsWith Checks if a string starts with a given substring If the substring is a string literal (and not a variable),