Skip to content

Instantly share code, notes, and snippets.

@mapkyca
Created August 1, 2013 15:39
Show Gist options
  • Save mapkyca/6132553 to your computer and use it in GitHub Desktop.
Save mapkyca/6132553 to your computer and use it in GitHub Desktop.
Strip email replies from an email message body. Note, this regex is simplistic, since stripping replies reliably is a whole world of hurt.
// Try simple regex, strip quoted (>) replies from an email
return preg_replace('/(^\w.+:\n)?(^>.*(\n|$))+/mi', '', $message);
// Try simple regex, strip replies from email using >
return preg_replace('/(^\w.+:\n)?(^>.*(\n|$))+/mi', '', $message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment