Skip to content

Instantly share code, notes, and snippets.

@heffcodex
Created September 29, 2020 10:05
Show Gist options
  • Save heffcodex/6d9979982d855dca685d86946d37cbd3 to your computer and use it in GitHub Desktop.
Save heffcodex/6d9979982d855dca685d86946d37cbd3 to your computer and use it in GitHub Desktop.
func EscapeMarkdownV2(text string) string {
escapeChars := "_*[]()~`>#+-=|{}.!"
return regexp.MustCompile(fmt.Sprintf("([%s])", regexp.QuoteMeta(escapeChars))).ReplaceAllString(text, "\\$1")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment