This site requires JavaScript, please enable it in your browser!
Greenfoot back
kiarocks
kiarocks wrote ...

2011/12/17

Anyone know how to divide strings?

kiarocks kiarocks

2011/12/17

#
I want a string that stores to pieces of info like this:
String stuff = "First info/Last info";
and then you can say, there is a slash there, its separate.
Duta Duta

2011/12/18

#
stuff.split("/")
returns the following array:
{"First info", "Last info"}
This works however much data there is in the array:
"Item 1:Item 2:Third item:The last item".split(":")
//returns
{"Item 1", "Item 2", "Third item", "The last item"}
This also works with multi-character splits:
"Item 1@*&Item 2@*&Third item@*&The last item".split("@*&")
//returns
{"Item 1", "Item 2", "Third item", "The last item"}
kiarocks kiarocks

2011/12/18

#
cool, thanks
You need to login to post a reply.