error_codes(lines) that scans thousands of log lines for codes like E-1234 — compiling the pattern once with re.compile outside the loop, then using the compiled object's .search per line. Return the list of codes found (first per line).error_codes(['boot ok', 'fail E-1042 retry', 'crash E-9 E-77'])
['E-1042', 'E-9']
One code per matching line, first occurrence.
Module-level or function-top compiled object.
m.group(0) when search hits.