INNER CODE UNIT · Python
remove_whitespace_signature
lefterisloukas/edgar-crawler · extract_items.py:280
def remove_whitespace_signature(match):
ws = r"[^\S\r\n]"
return f'{match[1]}{re.sub(ws, r"", match[2])}{match[4]}{match[5]}'
# Fix broken section headers (PART, ITEM, SIGNATURE)
text = re.sub(
r"(\n[^\S\r\n]*)(P[^\S\r\n]*A[^\S\r\n]*R[^\S\r\n]*T)([^\S\r\n]+)((\d{1,2}|[IV]{1,2})[AB]?)",
remove_whitespace,
text,
flags=re.IGNORECASE,
)
text = re.sub(
r"(\n[^\S\r\n]*)(I[^\S\r\n]*T[^\S\r\n]*E[^\S\r\n]*M)([^\S\r\n]+)(\d{1,2}[AB]?)",
remove_whitespace,
text,
flags=re.IGNORECASE,
)
text = re.sub(