Skip to content

Instantly share code, notes, and snippets.

@Lynnesbian
Created September 16, 2018 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lynnesbian/2ddb71f80741181752bc7d45184a3e3d to your computer and use it in GitHub Desktop.
Save Lynnesbian/2ddb71f80741181752bc7d45184a3e3d to your computer and use it in GitHub Desktop.
package main
import (
"flag"
"fmt"
"regexp"
"strings"
)
func main() {
flag.Parse()
args := (flag.Args())
zws := '\u200B'
charmatch := regexp.MustCompile("([A-Za-z\\d])")
spacematch := regexp.MustCompile("\\s")
emojimatch := regexp.MustCompile(fmt.Sprintf(":[^: %c]+:", zws))
out := "???"
out = spacematch.ReplaceAllString(args[1], "\n")
out = charmatch.ReplaceAllString(out, fmt.Sprintf(":%s_$1:%c", args[0], zws))
out = emojimatch.ReplaceAllStringFunc(out, func(s string) string {
return strings.ToLower(s)
})
fmt.Println(out)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment