Message296527
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> |
|
Date |
User |
Action |
Args |
2017-06-21 06:54:30 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, ezio.melotti, mrabarnett, William Budd |
2017-06-21 06:54:30 | serhiy.storchaka | set | messageid: <1498028070.44.0.578137010775.issue30720@psf.upfronthosting.co.za> |
2017-06-21 06:54:30 | serhiy.storchaka | link | issue30720 messages |
2017-06-21 06:54:30 | serhiy.storchaka | create | |
|