I am writing an extention to the String class, which includes all the methods of the original String class.
ex. charAt() charCodeAt() fromCharCode(), slice(), etc...
i am adding more methods to make manipulating strings in flash a breeze.
here are the methods i have working now.
returns a count of occurances of a specified character.
note: if your string is longer than 1 character this will return -1;
returns a hex encoded string.
returns a guaranteed uniq suffix to fix your cache problems.
prefix defaults to "?uniq=" so you dont need to include the argument.
returns a string after replacing a specified string with elements in an array
var s:XString = new XString("Michael is .::. because he never saw a .::. before .::.");
trace(s.replaceWithArray(new Array("amazed", "dog", "today"), ".::."));
Michael is amazed because he never saw a dog before today
n is a number that will be added to the charCode of each character.
ex. if your string is "abcd" and you use shiftCharCode(1) then your returned string will be "bcde"
this cuts away all white space before and after you string.
ex. your string is " trim me ", then your return string will be "trim me"
trims all white space before string
trims all white space after string
first runs trimEnds() and then checks string for certain requirements like having 1 '@' char, and having a domain name of at least 3 chars, and a suffix of at least 2 chars, and that the first char in the string is not the '@'
ex. [email protected]
will return true
@abc.tv will return false
will return false
will return false;
is supported, will return true
I KNOW there is more needed, if you have any needs for parsing strings in a certain way then let me know, i want to build this thing up.