Created
October 24, 2016 14:19
-
-
Save lewisjb/558d2b4ec9af7948055282d2509d9af7 to your computer and use it in GitHub Desktop.
Slack /s with regex and substitution
This file contains 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
TS.utility.msgs.wordReplace = function (text, replace_object) { | |
if(!replace_object){ | |
return text; | |
} | |
var rx_opts = (replace_object.g ? "g" : "") + (replace_object.i ? "i" : ""); | |
var rx = new RegExp(replace_object.str, rx_opts); | |
return text.replace(rx, replace_object.rpl.replace(/\\(\d+)/g, "$$1")); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment