Reputation: 17718
How can I match all characters including new line with a regex. I am trying to match all characters between brackets "()". I don't want to activate Dot matches all.
I tried
\([.\n\r]*\)
But it doesn't work.
(.*\) This doesn't work if there is an new line between the brackets.
I have been using http://regexpal.com/ to test my regular expressions. Tell me if you know something better.
Upvotes: 1
Views: 490
Reputation: 141927
The first example doesn't work because inside a character class the dot is treated literally (Matches the . character instead of all characters).
\((.|[\n\r])*\)
Upvotes: 2
Reputation: 269648
I'd usually use something like \([\S\s]*\)
in this situation.
The [\S\s]
will match any whitespace or non-whitespace character.
Upvotes: 5