[issue30720] re.sub substitution match group contains wrong value after unmatched pattern was processed

2017-06-20 Thread William Budd
William Budd added the comment: Doh! This has a really easy solution, doesn't it; just replace "." with "[^<]": re.compile('([^<]*?)', flags=re.DOTALL). Sorry about the noise. -- ___ Python tr

[issue30720] re.sub substitution match group contains wrong value after unmatched pattern was processed

2017-06-20 Thread William Budd
William Budd added the comment: I now see you're right of course. Not a bug after all. Thank you. I mistakenly assumed that the group boundary ")" would delimit the end of the non-greedy match group. I.e., ".*?" versus ".*?". I don't see a way to accom

[issue30720] re.sub substitution match group contains wrong value after unmatched pattern was processed

2017-06-20 Thread William Budd
William Budd added the comment: I don't understand... Isn't the "?" in ".*?" supposed to make the ".*" matching non-greedy, hence matching the first "" rather than the last ""? -- __

[issue30720] re.sub substitution match group contains wrong value after unmatched pattern was processed

2017-06-20 Thread William Budd
New submission from William Budd: pattern = re.compile('(.*?)', flags=re.DOTALL) # This works as expected in the following case: print(re.sub(pattern, '\\1', 'foo\n' '