import re

pdfContent = "\n\nBlah blah.\n\nDate:  2022-01-31\n\nOptional line here which sometimes does not show\n\nAmount:  123.45\n\n2: Blah blah.\n"

RE = re.compile(
    r"Date:\s+(\S+)(?:.*?"
    r"(Optional line here which sometimes does not show))?.*?"
    r"Amount:\s+(?P<amount>\S+)",
    re.DOTALL)

matches = RE.search(pdfContent)
date     = matches.group(1)
optional = matches.group(2)
amount   = matches.group("amount")

print(f"date     = {date}")
print(f"optional = {optional}")
print(f"amount   = {amount}")