How to use regular expressions (preferably in Python) to extract the value of "3" using only "A" in the expression. Each value is on a new line.
I try as follows, but does not work:
text = """ A ab 1 2 bc 3 4 B ab 5 6 bc 7 8 """ re_result = re.search('A.*bc\n+(\d)', text, re.S) print(re_result.group(1)) Throws 7, not 3.