import re SRC = "/root/troupe-standup/WORK-QUEUE.md" text = open(SRC, encoding="utf-8").read().splitlines() TOP = re.compile(r"^## ") Q = re.compile(r"^## Q(\d+)\s?(.*)$") ST = re.compile(r"^Status:(.*)$") # Show match behavior on a window of lines around Q1. for i, raw in enumerate(text): line = raw.rstrip() if 40 <= i <= 60: print(i, repr(line[:70]), "|Q=", bool(Q.match(line)), "|ST=", bool(ST.match(line))) PY