Clean email subject

Write codeMedium14 min

Your task

An inbox threads replies by their underlying subject. Given an email subject line, repeatedly strip from the front: any leading spaces, then a prefix 're:' or 'fwd:' (case-insensitive). Keep going until neither rule applies, then return what remains (leading spaces also removed). Only 're:' and 'fwd:' count, 'fw:' or 'reply:' do not. For example, 'Re: RE: fwd: Weekly sync' cleans to 'Weekly sync'.

Examples

clean_subject(subject: str) -> str
Example 1
Inputclean_subject("Re: RE: fwd: Weekly sync")
Output"Weekly sync"