Consider following code.
String s = "000000Xabcdefgh\nijkX00000000";
s = s.replaceAll("X.*X", "");
System.out.println(s);
I expect Xabcdefgh\nijkX
to get replaced with an empty string, but since there is a newline in the middle, nothing gets replaced. Why is the regex matching terminated at newline? How can I ignore newlines when matching regex?