Sujet : Re: re.DOTALL (Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.pythonDate : 18. Jul 2024, 01:54:25
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v79ljh$22itv$3@dont-email.me>
References : 1
User-Agent : Pan/0.158 (Avdiivka; )
On 17 Jul 2024 18:09:51 GMT, Stefan Ram wrote:
Below, I use [\s\S] to match each and every character.
I can't seem to get the same effect using "re.DOTALL"!
This might help clarify things:
text = "alpha\n<hr>\ngamma\n<hr>\nepsilon"
pattern = r'^(.*?)\n(<hr.*?)\n(.*)\n(<hr.*)$'
re.search(pattern, text, re.DOTALL).groups()
⇒
('alpha', '<hr>', 'gamma', '<hr>\nepsilon')