Re: re.DOTALL (Posting On Python-List Prohibited)

Liste des GroupesRevenir à cl python 
Sujet : Re: re.DOTALL (Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.python
Date : 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')

Date Sujet#  Auteur
17 Jul 24 * re.DOTALL3Stefan Ram
17 Jul 24 +- Re: re.DOTALL1Stefan Ram
18 Jul 24 `- Re: re.DOTALL (Posting On Python-List Prohibited)1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal