Message296506
pattern = re.compile('<div>(<p>.*?</p>)</div>', flags=re.DOTALL)
----------------------------------------------------------------
# This works as expected in the following case:
print(re.sub(pattern, '\\1',
'<div><p>foo</p></div>\n'
'<div><p>bar</p>123456789</div>\n'))
# which outputs:
<p>foo</p>
<div><p>bar</p>123456789</div>
----------------------------------------------------------------
# However, it does NOT work as I expect in this case:
print(re.sub(pattern, '\\1',
'<div><p>foo</p>123456789</div>\n'
'<div><p>bar</p></div>\n'))
# actual output:
<p>foo</p>123456789</div>
<div><p>bar</p>
# expected output:
<div><p>foo</p>123456789</div>
<p>bar</p>
----------------------------------------------------------------
It seems that pattern matching/substitution iterations only go haywire once the matching iteration immediately prior to it turned out not to be a match. Maybe some internal variable is not cleaned up properly in an edge(?) case triggered by the example above? |
|
Date |
User |
Action |
Args |
2017-06-21 02:38:32 | William Budd | set | recipients:
+ William Budd, ezio.melotti, mrabarnett |
2017-06-21 02:38:32 | William Budd | set | messageid: <1498012712.75.0.088701596169.issue30720@psf.upfronthosting.co.za> |
2017-06-21 02:38:32 | William Budd | link | issue30720 messages |
2017-06-21 02:38:31 | William Budd | create | |
|