Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to match anything (DOTALL) without DOTALL?

Tags:

python

regex

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?

like image 309
Ahmed Fasih Avatar asked Aug 15 '14 14:08

Ahmed Fasih


1 Answers

match "anything including newline" without DOTALL?

You can try with Character Classes or Character Sets

[\s\S]+
like image 185
Braj Avatar answered Oct 18 '22 04:10

Braj