Tag Archives: java.lang.IllegalArgumentException: Illegal group

java.lang.IllegalArgumentException: Illegal group

Open source software supply chain lighting plan, waiting for you>>>

Strings="$$";
s=s.replaceAll("\\s+\\$\\$","$$");

throw exception

java.lang.IllegalArgumentException: Illegal group

Use"\\$\\$"in the second parameter:

Strings="$$";
s=s.replaceAll("\\s+\\$\\$","\\$\\$");

The$is group symbol in regex’s replacement parameter

So you need to escape it

the second parameter also need to escape!