我正在寻找foo从Java中所有可能的后续查询字符串中删除参数及其值.
是否有正则表达式模式?
http://localhost/test?foo=abc&foobar=def
http://localhost/test?foobar=def&foo=abc
http://localhost/test?foo=abc
http://localhost/test?foobar=def&foo=abc&foobar2=def
Run Code Online (Sandbox Code Playgroud)
结果字符串将是
http://localhost/test?foobar=def
http://localhost/test?foobar=def
http://localhost/test
http://localhost/test?foobar=def&foobar2=def
Run Code Online (Sandbox Code Playgroud)
ale*_*lex 18
这个正则表达式应该与GET参数及其值相匹配......
(?<=[?&;])foo=.*?($|[&;])
Run Code Online (Sandbox Code Playgroud)
只需用空字符串替换它.