String manipulations

In a previous post to this thread by david…

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

fine :stuck_out_tongue: hehe

Seems to be a big debate. I already stated I didn’t know enough about either to boast my opinion on likenesses.

okay - so here is another one

what if a string is like this:

does the delimiter become ("\")?

I tried doing a prototype for it - but its chopping off a letter of some the string

return b;

anyone see what is wrong- it should be obvious - but I must be blind!

thanks for all the great posts by the way!

i’m gonna have to agree that strings are like arrays, in that they are an array of characters, just with a different syntax than an actual array. see, you can pull just one character from a string, just like you can pull one position and object from an array

It’s not really true. Arrays CAN be like strings and or like XML node trees, but both node trees and array can be so much more. A string can only be a string. The imporant part to a programer is that strings, array and xml nodes can all be manipulated by SOME of the same methods. (at least they seem the same when writing them.)


these all work the same way… using the first object in the hierarchy as the number 0 item and counting up from there. The difference is that you can’t use a ‘split();’ method on an XML tree. Nor can you use ‘childNode’ on anything but an XML tree. So the answer is that they are not the same thing… they just share some common methods.

I guess that’s just a repeat of what I said before… but I guess I thought that I was being a little more clear in this post. :wink:


yes “\” is correct because “” will escape the second quote. in this case you need to escape the backslash, thus “\”.

you get strange results because \f is a special character. solution is to (again) escape the backslash:

str = ‘path\subdir\lalal\file’;

incidentally, no need to split the string into an array with that function, lastIndexOf will help you out:


and in the string is like an array debate, i’m firmly in the “not the same thing” camp.

*Originally posted by sbeener *
**and in the string is like an array debate, i’m firmly in the “not the same thing” camp. **
Ouuhh… That one hurt… Let me explain then: I said that I find arrays [SIZE=1]a bit[/SIZE] similar to strings [SIZE=1]sometimes[/SIZE] because of the .length thing, and because elements of a String can be accessed quite similarly to Arrays elements (in very simple cases). Of course I never said they were the same, but the way I see it, you could use Arrays instead of Strings in most cases (and in C, C++ and Java, Strings are in fact arrays of char if I’m ot mistaken so I don’t how Flash works, but it must be similar).

pom :stuck_out_tongue:

roflmao… poor Pom…

I knew what you meant anyway… don’t listen to us peanut gallery types. We love you Pom, and you go on thinking that strings and array are whatever they need to be to you, to let you grasp them. I often use associations for things to help me remember how to use them. Rarely do they make sense to anyone other than myself.

Haha, word association is about 95% of the method I have to use to memorize things. No one can understand it, but it works good for me. You could say the word apple and I will remember I have to return a rented movie, I will remember that because there was an apple in the movie or something. Very odd, I don’t even understand it, my brain just works it out on its own.

This thread has been very educational to me. I stood back and learned. I still need to learn more of the basics though. Whenever I seem to run a search for tutorials on strings I get all these entries for learning RegEXP for MX. Is this what I need to know?

Thanks Upu :slight_smile:

And Lost, RegEXP are useful, so you should definitely learn that, but if you want to learn the Strings methods, open the AS dictionary and just try them…

pom :asian:

Sounds fun fun fun, I guess I will do that friday or saturday. I won’t be home tomorrow so I can’t try it then.

Time to find that RegEXP site again. It looked very useful, it gave a list of things and described what each did.

can you guys explain a little bit of what ‘RegEXP’ is?.. and is it something that’s new with MX, because I’ve never heard of it.

There is the link I found on it. It may be useful. It says it is for Flash 5 and MX david.

RegExp = regular expressions.

very powerful method of pattern matching in strings.

ily - no hard feelings! consider … you can have an array of strings, but can you have an string of arrays?

Ahaha! I was waiting for your answer Supra :stuck_out_tongue:
I agree with you, their are not the same, but what’s a String? An array of char. So let’s settle with this: Strings are a very particular kind of arrays… Or do you disagree?

pom :slight_smile:

Ah ha: Supra, this:
‘you can have an array of strings, but can you have an string of arrays?’
is EXACTLY the words i was thinking when i started posting that strings are not like arrays!

And then i thought

var string = “[1,2,3], [4,5,6],[7,8,9]” and so on…

Basically, you can put whatever in a string, cantcha?

But you don’t really have an array in a string in that case… You’d have to parse for half an hour before you can reconstruct the array :slight_smile:

Hey, YOU were saying they’re the same, and now you deny the obvious?! lol

It’s not one array, it’s 3 of em in that string, so you’d just split at “,” and then array1 = resultOfSplit[0], array2 = resultOfSplit[1} etc…