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