re = /^(.*?)(?=On\s+\d{2}\-\d+\-\d+|\#{2}\-.*?\-\#{2})/
str = 'Second reply. #2
Met vriendelijke groet,
{sender name}
{company details}
On 25-02-15 14:38, {email name} wrote:
> [Ticket ID: 54e70396110971424425] Re: 54e70396110,678567.971424425
>
> ##- Please type your reply above this line -##
>
> Your request (54e70396110971424425) has been deemed solved. To reopen,
> please reply to this email or login on {name} to reply.
>
> ------------------------------------------------------------------------
>
> Feb 25, 14:38
>
> Dear Test user,
>
> First reply. #1
>
>
> {name}
> {company details}
>'
# Print the match result
str.match(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html