I have implemented the regex expression to remove all the special characters with empty strings and remove space(if any), which is working fine in my code but sonarQUbe is complaining as this is non-compliant solution, Can anyone tell me how to fix this issue
String c = "test10101010test%79%% %%% $$$ \t \n $$$#$@^$%~`***c 33";
Pattern pt = Pattern.compile("[\\W\\s+]");
Matcher match= pt.matcher(c);
while(match.find())
{
c=c.replaceAll("\\"+match.group(), "").toLowerCase();
}
System.out.println(c);
I am getting error at "[\\W\\s+]". Getting below error
Remove duplicates in this character class.
Can anyone suggest how to fix this issue?