views:

106

answers:

2

In my forum, users can reply through email. I am handling mails from their reply. When they are replying the original message getting appended. I want to get only the reply message not the original message.

I have to write regular expression for gmail & hotmail.

I written regex for gmail as follows :

\n.*wrote:(?s).*--End of Post--

It is removing the original message except date. I want to remove the date also.

before removing the original message :

 hi 33

 On Tue, May 11, 2010 at 4:18 PM, Mmmmm, Rrrrr
 <[email protected]>wrote:

  The following update has been posted to this discussion:
  ----------------------------------------------------------------------
  test as user 222
  ----------------------------------------------------------------------
  [$MESSAGE_SIGNATURE_HEADER$]



  --End of Post--

When I use the above regex it is filtering as follows :

 hi 33

 On Tue, May 11, 2010 at 4:18 PM, Mmmmm, Rrrrr

Here i want only the actual message 'hi 33' not that date. How can I filter the date using above regex?

Also I need regex for Hotmail also.

I appreciate for any reply. Thanks in advance.

A: 

Try this one (this will match everything that should be removed):

On\s+\w+,\s+\w+\s+\d+,\s+\d+\s+at\s+\d+:\d+\s+\w+,.*?wrote:.*?--End of Post--

Or the simpler version:

On.*?wrote:.*?--End of Post--
Pessimist
ravi ravi
Maybe the reason it works in one but not the other is because in the "application" you are not setting the dot (.) to also match the newline "\n". You have to do this to make it work.
Pessimist
How to ignore the new lines ? Could u modify that expression and tell me ?
ravi ravi
Try adding `(?s)` to the start of the regex to set singleline mode.
Tim Pietzcker
A: 

I got it. To skip new lines i modified in this way ....

On\s+\w+,\s+\w+\s+\d+,\s+\d+\s+at\s+\d+:\d+\s+\w+,\s+\w+,\s+\w+(?s).?wrote:.\n(?s).*--End of Post--

ravi ravi