Created
July 27, 2015 14:23
-
-
Save duhast/4b88ded69422232398c3 to your computer and use it in GitHub Desktop.
CoffeeScript / JavaScript function to compose a subject of an email reply
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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