From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/string.as | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/string.as (limited to 'Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/string.as') diff --git a/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/string.as b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/string.as new file mode 100644 index 0000000..fae05fb --- /dev/null +++ b/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/string.as @@ -0,0 +1,77 @@ +//--------------------------------------------------------------------------- +// String object rewrite v1.5 +// Branden J. Hall +// Fig Leaf Software +// +// Thanks to Damien Morton for the indexOf code +// Thanks to Steven Yi for the *great* idea for the split code +// Thanks to Dave@opaque.net for an additional speed boost to split +// Thanks to Jobe Makar for spotting a bug in split +//--------------------------------------------------------------------------- +String.prototype.charAt = function(index){ + return(substring(this, index+1, 1)); +} + +String.prototype.concat = function(){ + var r = this.toString(); + for (var i=0; i= 0) && (substring(this, i--, size) != sub)); + return (i == -1 ? -1 : (i)); +} + +String.prototype.slice = function(s, e){ + return(substring(this, s+1, e-s)); +} + +String.prototype.split = function(d){ + if (d != null){ + var r = new Array(); + var size = this.length; + var c = 0; + var n = 0; + if (d != ""){ + for (var i=0; i<=size; ++i){ + if (substring(this, i+1, 1) == d){ + r[n] = substring(this, c+1, i-c); + c = i+1; + ++n; + } + } + if (c != i){ + r[n] = substring(this, c+1, i-c); + } + }else{ + for (var i=0; i