5

My regexp needs both the default non-newline-matching dot and the re.DOTALL dot (. matches newline). I need several of the former and just one of the latter within a single regexp. Nevertheless, because I need one dot to match newlines, I have to use DOTALL, and use [^\n] several times to get the default "anything except newlines" behavior.

I'd like to get rid of the DOTALL, replace those [^\n] with . and have a more complicated way of matching "anything including newlines" in the one place that I need.

So the question is: what is the regexp syntax to match "anything including newline" without DOTALL?

Ahmed Fasih
  • 6,458
  • 7
  • 54
  • 95

2 Answers2

7

match "anything including newline" without DOTALL?

You can try with Character Classes or Character Sets

[\s\S]+
Braj
  • 46,415
  • 5
  • 60
  • 76
5

I always use r"[\s\S]" all whitespace and non-whitespace, so everything.