How to remove redundant "Re:" in the email subject
def subject_clean(subject)
result = subject.dup
if result.scan(/(Re:\s)+?/i).length > 0 or !result.match(/Re\[\d+\]:\s/i).nil?
result = "Re: #{result.gsub!(/(Re:\s)+?|Re\[\d+\]:\s/i, "")}"
end
return result
end
As a result, we get rid of the terrible "Re: Re: Re:" or "Re [5]: Re: Re: Re [2]"
Written by Alex Lushpai
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#