Given an email subject line, I\'d like to clean it up, getting rid of the \"Re:\", \"Fwd\", and other junk. So, for example, \"[Fwd] Re: Jack and Jill\'s Wedding\" should turn i
The following regex will match all of the cases in the way that I would expect it to do so. I'm not sure if you will agree, because not every case has been explicitly documented. It is almost certainly possible to simplify this, but it is functional:
/^((\[(re|fw(d)?)\s*\]|[\[]?(re|fw(d)?))\s*[\:\;]\s*([\]]\s?)*|\(fw(d)?\)\s*)*([^\[\]]*)[\]]*/i
The final result in the match will be the stripped subject.