Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex with newline? #66

Open
billynoah opened this issue Mar 21, 2018 · 0 comments
Open

Regex with newline? #66

billynoah opened this issue Mar 21, 2018 · 0 comments

Comments

@billynoah
Copy link

billynoah commented Mar 21, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant