I can not understand why the following code is not working properly
"Hello/You/There".replaceAll("/", "\\/");
- Expected Result:
Hello\/You\/There - Actual output:
Hello/You/There
Do I need to hide slashes? I didn’t think so, but I also tried the following against my will ... did not work
"Hello/You/There".replaceAll("\\/", "\\/");
In the end, I realized that I do not need a regular expression, and I can just use the following, which does not create a regular expression
"Hello/You/There".replace("/", "\\/");
However, I still would like to understand why my first example does not work.
java regex
Juan Mendes Mar 05 2018-12-12T00: 00Z
source share