I can't figure out why the following code doesn't behave as expected
"Hello/You/There".replaceAll("/", "\\/");
- Expected output:
Hello\/You\/There
- Actual output:
Hello/You/There
Do I need to escape forward slashes? I didn't think so but I also tried the following against my will ... didn't work
"Hello/You/There".replaceAll("\\/", "\\/");
In the end I realized I don't need a regular expression and I can just use the following, which doesn't create a regular expression
"Hello/You/There".replace("/", "\\/");
However, I'd still like to understand why my first example doesn't work.