query string - Java: How do I remove parameter from querystring -


i want remove querystring attribute url, tried regex didn't exact solution this. please me out of it. eg:

string qstring = "category=popular&code=14290115"; qstring = qstring .replaceall("(?<=[?&;])code=.*?($|[&;])","");  output: category=popular& 

the above regex removing attribute not removing & symbol. please suggest me this.

don't use regex this. it's utter nightmare because character percent-encoded, e.g. ?foo=bar same ?%66oo=%62ar. parse url, query string, rebuild it. take @ uribuilder , urlencodedutils out of apache commons http client.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -