New submission from steven Michalske: When writing a regular expression to match the following text.
d = """num interesting lines: 3 1 2 3 foo""" # I only want to match the interesting lines. m = re.match(".+?: (\d+)\n((?:.+\n){\1})", d) print(m) # prints: None # Expected a match object. print(m.groups()) # Causes Exception. # Expected: ('3', '1\n2\n3\n') # Works with hard coded match length. m = re.match(".+?: (\d+)\n((?:.+\n){3})", d) print(m.groups()) ('3', '1\n2\n3\n') Workaround it to have two regular expressions. one to extract the desired length the second to extract the interesting lines. ---------- components: Regular Expressions messages: 211551 nosy: ezio.melotti, hardkrash, mrabarnett priority: normal severity: normal status: open title: re does not allow back references in {} matching operator type: behavior versions: Python 3.5 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20678> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com