Skip to content

Instantly share code, notes, and snippets.

@temochka
Created November 23, 2011 17:26
Show Gist options
  • Save temochka/1389288 to your computer and use it in GitHub Desktop.
Save temochka/1389288 to your computer and use it in GitHub Desktop.
Simple gist for fetching reply without quoted parts and signature from inbound message
module ReplyParser
TEXT_PLAIN_SPLITTER = /^((> )?\/\/ ADD YOUR REPLY ABOVE$)|( *\-\-\-\-\- .+ \-\-\-\-\-)/
class << self
def parse_reply_text(body)
splitter = TEXT_PLAIN_SPLITTER
prepare_reply_text(body.split(splitter).first)
end
private
def prepare_reply_text(text)
text.gsub!(/^>.*$/u, '')
text.strip
end
end
end
plain_text = <<BODY
This is reply text.
> // ADD YOUR REPLY ABOVE
> This is a quoted text
---
User signature
BODY
puts ReplyParser.parse_reply_text(plain_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment