String.replaceAll() weirdness?
By accident I found this oddity in replaceAll(). Is it a bug or a feature?
String str = "random|string";
System.out.println(str);
System.out.println(str.replaceAll("|", " "));
This code results in this output:
random|string
r a n d o m | s t r i n g
I know that I need to escape the vertical bar in order to replace the character correctly, that'snot the issue here.
What happens in the call to replaceAll and why doesn't it throw an exception? Somehing clearly gets replaced by a space but just an OR shouldn't be a correct regular expression, unless it's interpreted as "nothing OR nothing". If that's the case, what is this nothingness in between the characters and what else can be done with it?
Ove, slightly confused.

