Deutsch English Français Italiano |
<v79ljh$22itv$3@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Lawrence D'Oliveiro <ldo@nz.invalid> Newsgroups: comp.lang.python Subject: Re: re.DOTALL (Posting On Python-List Prohibited) Date: Wed, 17 Jul 2024 23:54:25 -0000 (UTC) Organization: A noiseless patient Spider Lines: 15 Message-ID: <v79ljh$22itv$3@dont-email.me> References: <DOTALL-20240717190848@ram.dialup.fu-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 18 Jul 2024 01:54:26 +0200 (CEST) Injection-Info: dont-email.me; posting-host="9a105d93edfb2dbcb4f0f989ba6cd483"; logging-data="2182079"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WzouO5z2tRMUqC7kRtq6s" User-Agent: Pan/0.158 (Avdiivka; ) Cancel-Lock: sha1:DIcBWZ5chmuDnQmmeKoK8dpE5is= Bytes: 1385 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')