Skip to content

Instantly share code, notes, and snippets.

@duhast
Created July 27, 2015 14:23
Show Gist options
  • Save duhast/4b88ded69422232398c3 to your computer and use it in GitHub Desktop.
Save duhast/4b88ded69422232398c3 to your computer and use it in GitHub Desktop.
CoffeeScript / JavaScript function to compose a subject of an email reply
makeReplySubject = (sourceSubject) ->
match = sourceSubject.match(/^Re\s*(\[\s*(\d)+\s*\])?:\s*(.+)$/i)
return "Re: #{sourceSubject}" unless match?
if match[2]?
replyNumber = parseInt(match[2])
"Re [#{replyNumber + 1}]: #{match[3]}"
else
"Re [2]: #{match[3]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment