in reply to regular expression issue
Not knowing what kind of variation there could be in other messages of this type, I would take the following conservative approach to parsing it:
The idea is to match the issuer and message sections and then trim each appropriately. If there happen to be similar messages which don't conform exactly to this format, at least you'll get something back.if (m/Reply issued by (.*?):(.*)/) { my $issuer = $1; my $msg = $2; if ($issuer =~ m/([^\\]+)@/) { $issuer = $1; } $msg =~ s/\A\s*'\(ACK\)\s*//; $msg =~ s/\s*'\s*\z//; # results are in $issuer and $msg } else { # not a Reply issued by message }
Update: Changed \a in regex to \A - thanks moritz!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regular expression issue
by sumesh.sasi (Initiate) on Jun 06, 2008 at 08:11 UTC | |
by Anonymous Monk on Jun 06, 2008 at 10:03 UTC | |
by sumesh.sasi (Initiate) on Jun 06, 2008 at 11:34 UTC |