This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients William Budd, ezio.melotti, mrabarnett, serhiy.storchaka
Date 2017-06-21.06:54:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1498028070.44.0.578137010775.issue30720@psf.upfronthosting.co.za>
In-reply-to
Content
Atomic groups can help you: '<div>((?><p>.*?</p>))</div>'.

But this feature is not supported in the re module yet (see issue433030). You can use the third-party regex module which is compatible with the re module and supports atomic grouping.

>>> import regex as re
>>> pattern = re.compile('<div>((?><p>.*?</p>))</div>', flags=re.DOTALL)
>>> print(re.sub(pattern, '\\1',
...              '<div><p>foo</p>123456789</div>\n'
...              '<div><p>bar</p></div>\n'))
<div><p>foo</p>123456789</div>
<p>bar</p>
History
Date User Action Args
2017-06-21 06:54:30serhiy.storchakasetrecipients: + serhiy.storchaka, ezio.melotti, mrabarnett, William Budd
2017-06-21 06:54:30serhiy.storchakasetmessageid: <1498028070.44.0.578137010775.issue30720@psf.upfronthosting.co.za>
2017-06-21 06:54:30serhiy.storchakalinkissue30720 messages
2017-06-21 06:54:30serhiy.storchakacreate