> > > I have some lines in a text file like > ADD R1, R2 > ADD3 R4, R5, R6 > ADD.MOV R1, R2, [0x10] > ....
Actually I want to get 2 matches. ADD R1, R2 and ADD.MOV R1, R2, [0x10] > because these two lines are actually "ADD" instructions. However, "ADD3" is > something else. > >>> s = """ADD R1, R2 ... ADD3 R4, R5, R6 ... ADD.MOV R1, R2, [0x10]""" >>> import re >>> pattern = re.compile(r"^ADD\b.+") >>> for line in s.splitlines(): ... if re.search(pattern, line): ... print(line) ... ADD R1, R2 ADD.MOV R1, R2, [0x10] -- https://mail.python.org/mailman/listinfo/python-list