I have a PHP application which interfaces with a payment processor to handle credit cards. Sometimes, the post response from the processor fails (e.g. momentarily glitch in the matrix), and we don't get the automated notification of the payment. In these cases, we fall back to entering the data from a confirmation email that's always sent. I want my code to parse out the text of the email to get the data, and it seems like a perfect use case for preg_match_all. The problem is that the email is badly formatted: it comes in I have a PHP application which interfaces with