Lets say I have a string that is a Path ( c:/thisdoc/thisdir/thisfile)-
and I want to only get certain info from the string - such as “thisfile” - do I use split or splice? Any suggestions or tutorials that someone could point me to would be much appreciated.
//you have a string
myStr="c:/thisdoc/thisdir/thisfile";
//a is an array containing the elements separated by /
a=myStr.split("/");
//file is the last element of that array
file=a[a.length-1];
trace (file);
you could also use “lastIndexof” to get the last dash, and then retrieve the remaining substring based on that value…
How about a string manipulating contest?
And strings are not like arrays…are they…? lol The more i think about theur differences, the less there are…well anyway, they’re both usefull, so go get that (Moock) book!
well lost… really string manipulation is not that tough. If I know you, you’d pick up most of the principals pretty quickly.
You’ll need to know the basics of it to work with XML docs anyway. Many of the methods used on strings are very similar to methods used on XML nodes and Array for that matter. (which is why Pom says they are similar to each other.)
There are the links on info I have on Arrays, I think it is pretty informative. Figured if anyone else read this and wanted to learn, they could use those links.
There are, I guess, quite a few methods that you can use on strings which would be hard to post all of here. If I can find a good tutorial, I’ll pass it on… otherwise it looks like that will probebly be my next tutorial after the xml one. both the XML tutorial, and a ‘string’ tutorial will compliment each other anyway… so it certainly wont hurt to be creating both close together.
arrays arn’t like strings…strings is just a string of caracters all joined to gether, where as an array is an ordered set of alike things like a set of numbers, letters, or values…arrays are easier to refer to a certian entry as well…you just use the myArray*, with strings you would have to chop and change them to get the right thing…
I meant to reply to this yesterday…but my computer was anoying me…hehe oh well