Using ^ to match beginning of line in Python regex May 26, 2023 by Tarik re.findall(r'^PY (\d\d\d\d)', wosrecords, flags=re.MULTILINE) should work