EmailReplyParser icon indicating copy to clipboard operation
EmailReplyParser copied to clipboard

Regex with newline?

Open billynoah opened this issue 7 years ago • 0 comments

I have some emails that come in with a pattern like:

From: NAME
Sent: blah blah blah

These don't match the regex /^\s*(From\s?:.+\s?(\[|<).+(\]|>))/ because they lack the <EMAIL> segment. So rather than change the existing I tried a regex like:

/^\s*(From\s?:.+\nSent:\s?.+)/

But this fails to match in isQuoteHeader() due to the way newlines are replaced at the beginning of the parse() method. So I changed it to:

/^\s*(From\s?:.+(\n| )Sent:\s?.+)/

This matches either a newline or it's replacement a space- and seems to work but I end up with a single line and I'd rather not have the resulting text be altered. Also, I'm not entirely sure that this wouldn't end up matching things incorrectly in the isQuoteHeader() method. Can you offer any advice here on how to match a multiline pattern? Is there a cleaner way to handle this?

Thanks again for the excellent library, it's really coming in handy.

billynoah avatar Mar 21 '18 21:03 billynoah