|
Posted by Charles on 06/20/05 05:34
I'm new to this regular expression stuff. I'd like to use preg_replace to
eliminate a known multi-line signature from the body of an E-mail. Say the
body text is in $body, and the sig is this
---
Sig line1
Sig line2
Sig line3
If I could just get rid of that, it would be pretty good. But I also get this
kind of junk a lot, since messages are being quoted:
> ---
> Sig line1
> Sig line2
> Sig line3
or
>> ---
>> Sig line1
>> Sig line2
>> Sig line3
so I thought I'd be smart and tried:
$body = preg_replace("/---.*?Sig line1.*?Sig line2.*?Sig line3/","",$body);
but this erased the entire message somehow. So I thought I'd go back to
basics and tried:
$body = preg_replace("---","",$body);
$body = preg_replace("Sig line1","",$body);
$body = preg_replace("Sig line2","",$body);
$body = preg_replace("Sig line3","",$body);
but this erased everything too.
I'm kinda stumped. Why are these erasing the entire message? And what's the
actual smart way to erase this signature when it can have any amount of white
space and >'s between lines?
Thanks for any help.
[Back to original message]
|