preg_replace vs preg_match

Hi, thanks for trying to help, but that link I gave uses pre_match within a loop with break command that when it meets the pattern criteria, just breaks the loop to not appened the rest of email line to the message and this way, quoted area will be removed. but with preg_replace how can I have IF statement with break command to kick it out from the loop to not appened the rest of emal to the message? preg_match does not return anything, it just gives $matches as array as 3rd param, but with preg_replace it returns something, so how to re-write the code on that link with preg_replace to do the same behavior?