We are running
- Community Edition, Version 9.9 (build 65466), installed from zip
We have a piece of code to remove leading and trailing quotes from a string
theString.replaceAll("^\"|\"$", "");
this gives us : Alternatives in regular expressions should be grouped when used with anchors (java:S5850)
so we replace it with (as suggested as compliant solution)
theString.replaceAll("(?:^\")|(?:\"$)", "")
but now there is a new code smell : Unwrap this unnecessarily grouped subpattern. Non-capturing groups without quantifier should not be used (java:S6395)
How can we resolve this ?