java - Not able to perform String Splitting -
i have string in not able find way out split ever necessary. below scenario.
i using java
string querystring = "string1=1&string2=2&string3=3&string31=31&string32=32....&string4=4";
i wanted output below
string1=1 string2=2 string3=3&string31=31&string32=32.... string4=4
i tried querystring.split("&");
splits string3,strin31,string32...and on well.
please me out in this
if accept in way snippet it....
but feel not @ recommendable...
i'm want remain json... not suitable requirement.
my code here:
public static void main(string[] args) { string querystring = "string1=1&string2=2&string3=3&string31=31&string32=32&string4=4"; int count = 1; string queryparam = ""; try{ while(count == 1 || queryparam.length() > 0){ queryparam = querystring.substring(querystring.indexof("string" + count + "="),querystring.indexof("string" + ++count + "=")-1); system.out.println(queryparam); } }catch(exception e){ queryparam = querystring.substring(querystring.indexof("string" + --count + "=")); system.out.println(queryparam); } }
Comments
Post a Comment