View Full Version : Convert a comma separated string into an array?

1 Nov 2009, 2:29 PM
Hey guys,

I don't think I am searching for the right name for this… I have a string like so:


And I need to turn it into a legitimate array. What's the easiest way to do this with Ext?

1 Nov 2009, 2:41 PM

1 Nov 2009, 6:34 PM
I am assuming the answer is to just use plain ol JS then? That's cool, just thought there might be an Ext method to use.

By the way, .join does in reverse of what I was asking. I already have a string, I want to split (.split should work) to create the array.


Mike Robinson
2 Nov 2009, 7:46 AM
"Split" and "join" are pretty standard operations these days, which JavaScript implements in the usual way.

For more complex tasks, you also have regular expressions in JavaScript, which are basically very-sophisticated string matching patterns.

JavaScript, like Perl, is very much involved with doing tasks that routinely need to be able to "chop-up character strings and stitch them back together again in many clever ways, very fast." The array, list, hash, and regular-expression features of such languages are a very basic staple that you'll find yourself using very often. Learn them well. "It sucks" /:) to find that you have just spent a couple hours painstakingly implementing something by-hand, only to find that it was already implemented (and, much more cleverly...) in the language itself. (Show of hands from the Peanut Gallery as to how many times we've all done that? ~o))