简体   繁体   中英

How to match any character in regex

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.

I'd usually use something like \([\S\s]*\) in this situation.

The [\S\s] will match any whitespace or non-whitespace character.

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])*\)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM