The metacharacters in a Java RegEx are:
([{^$|)?*+.
If you want to treat them as ordinary characters you have two options:
1. Escape the metacharacter with a backslash,
2. Enclose the whole string that contains metacharacters within Q and E Q means: "quotes all characters until E", while E ends the quotes.
String test = "I want to replace the . with the ,";
String replaced = test.replaceAll("\.", ",");
System.out.println(replaced);
The output will be:
Output: I want to replace the , with the ,