I have below content in text file
some texting content
Test
I read it from
If you want your dot (.) to match newline also, you can use Pattern.DOTALL flag. Alternativey, in case of String.replaceAll(), you can add a (?s) at the start of the pattern, which is equivalent to this flag.
From the Pattern.DOTALL - JavaDoc : -
Dotall mode can also be enabled via the embedded flag expression (?s). (The s is a mnemonic for "single-line" mode, which is what this is called in Perl.)
So, you can modify your pattern like this: -
expectedStr = inputString.replaceAll("(?s)", "Content");
NOTE: - You don't need to escape your angular bracket(<).