String manipulations

I have a string manipulation questions:

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.

thanks!

split is for arrays

splice is for string manipulation

I am not sure how to use them, I only know that “splice” is the one you are looking for out of those 2.

You have to use split:

//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);

pom :asian:

Hmm, I could have sworn splice was for strings and split was for arrays. Maybe I am confusing myself again…

well, strings and arrays aer a bit alike… :slight_smile:

Good to know…good to know. I really need to read up more on both. Actually, I really need to start buying books for what I am learning…haha.

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!

… ahh. .a string manipulation contest… I might actually have some luck with that one. Good idea Eyez

i think i need to get a book too…it would be good to actualy know what im doing for a change… :)hehe

Ok, I am screwed enough in the AS contest, please don’t start a string manipulation contest…haha. Just kidding:)

Hmm… Strings are a bit like arrays, Eyez. Just a bit, but they are :slight_smile: I know C. Moock would disagree with me on that one, but hey…

pom :asian:

Sounds confusing… I am going to jump out of this thread before I hang myself with a String from an Array:P

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.)

Do you know any good tutorials on strings?

I have good info on Arrays, I just need to find something to teach me strings.

http://www.flashmagazine.com/html/480.htm
http://www.flashmagazine.com/html/509.htm

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.

Well… most of it’s pretty straight forward.

name the string and then call a string method. ie

someSting.length();

gives you the length of the value of the string.

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.

Awesome, thanks david.

Working on one too…sometimes, when i get time…will take some time…ti-i-i-ime is on my side…

…yyyes it iss. :nerd:

Hey Eyez, are you working on an XML tute or a String methods tute (for Lost, the best ressource I know: the AS dictionary)?

pom :asian:

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 :slight_smile: