Поскольку вы хотите просто сопоставить значения параметров, вы можете использовать это регулярное выражение, используя осадки, чтобы сопоставить только значения и заменить их на xx
или что угодно.
(?<=[&=])[^=&"\n ]*(?=[&" ]|$)
Демонстрация
Проверьте этот код Java,
List<String> list = Arrays.asList("https://stackoverflow.com/questions/54937940?a=5",
"https://stackoverflow.com/questions/54937940?a=5&b=7", "*266 open() \"/usr/local/nginx/html/user-accounts/malphas/check\" failed (2: No such file or directory), client: 10.254.3.0, server: ji, request: \"GET /user-accounts/malphas/check?sid=ExecAuthoritySetting HTTP/2.0\", host: \"jilcom\", referrer: \"https://jicom/user-accounts/authority/authoritysettings/authoritysetting/detail?sid=ExecAuthoritySetting&roleId=1812\"\"tid\"");
list.forEach(x -> {
System.out.println(x + " --> " + x.replaceAll("(?<=[&=])[^=&\"\\n ]*(?=[&\" ]|$)", "xx"));
});
Печать,
https://stackoverflow.com/questions/54937940?a=5 --> https://stackoverflow.com/questions/54937940?a=xx
https://stackoverflow.com/questions/54937940?a=5&b=7 --> https://stackoverflow.com/questions/54937940?a=xx&b=xx
*266 open() "/usr/local/nginx/html/user-accounts/malphas/check" failed (2: No such file or directory), client: 10.254.3.0, server: ji, request: "GET /user-accounts/malphas/check?sid=ExecAuthoritySetting HTTP/2.0", host: "jilcom", referrer: "https://jicom/user-accounts/authority/authoritysettings/authoritysetting/detail?sid=ExecAuthoritySetting&roleId=1812""tid" --> *266 open() "/usr/local/nginx/html/user-accounts/malphas/check" failed (2: No such file or directory), client: 10.254.3.0, server: ji, request: "GET /user-accounts/malphas/check?sid=xx HTTP/2.0", host: "jilcom", referrer: "https://jicom/user-accounts/authority/authoritysettings/authoritysetting/detail?sid=xx&roleId=xx""tid"