'Any character including newline - Java Regex

I thought it may be [.\n]+ but that doesn't seem to work?



Solution 1:[1]

Edit: While my original answer is technically correct, as ThorSummoner pointed out, it can be done more efficiently like so

[\s\S]

as compared to (.|\n) or (.|\n|\r)

Hints:
\s: any whitespace character
like (space/newLine/...)

\S: any non-whitespace character
like (characters /sepcial characters/ numbers / ...)

Solution 2:[2]

Try this

((.|\n)*)

It matches all characters multiple times

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ahmednabil88
Solution 2 Thavas Antonio