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
Post a Comment