How to match anything (DOTALL) without DOTALL?

My regex needs both a point not matching a newline and a period re.DOTALL

( .

matching a newline). I need a few of the former and only one of the latter in one regex. However, since I need a single dot to match the news, I have to use DOTALL

and reuse [^\n]

multiple times to get the default "nothing but newline" behavior.

I would like to get rid of DOTALL

, replace those [^\n]

with, .

and have a more complex way of matching "nothing, including newlines" in one place that I need.

So the question is, what is the syntax of regexp to match "nothing, including a newline", without DOTALL

?

+3


source to share


2 answers


I always use r"[\s\S]"

all whitespace and non-whitespace, so that's all.



+2


source


matches "nothing, including a newline" without DOTALL?

You can try with Character Classes or Character Sets



[\s\S]+

      

+4


source







All Articles