java - Split string using substring -


i have following string, let's call mystring:

file=android.txt&data=it contains android data 

how can extract substrings android.txt , it contains android data?

i tried mystring.substring(mystring.lastindexof('=')+1, mystring.length() ); returns it contains android data.

you can use split method string class.

split file=android.txt&data=it contains android data

on & array of "file=android.txt" , "data=it contains android data".

then can split each of elements on =

file=android.txt -> file, android.txt
data=it contains android data -> data, it contains android data

so code can like

foreach element in data.split(&)    array = element.split(=)    second element array 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -