I've put in a solution that may work, but it might have unintended side effects too.
I figure the best way to find out is to ship it and see: http://play.golang.org/p/JNHj3PtZaO
package main import "fmt" import "regexp" import "strings" var ( regMentions = regexp.MustCompile(`(?:^|\W)([+@](\S+))`) regSpecial = regexp.MustCompile("([\\\\_*{}[\\]()#-.!])") replSpecial = `\$1` ) func main() { str := `@_d\a*n)]_ foo +_dan_ +_dan_` fmt.Println(str) for _, s := range regMentions.FindAllString(str, -1) { str = strings.Replace(str, s, regSpecial.ReplaceAllString(s, replSpecial), 1) } fmt.Println(str) }
@dan should now work
@Velocio started
London Fixed Gear and Single-Speed is a community of predominantly fixed gear and single-speed cyclists in and around London, UK.
This site is supported almost exclusively by donations. Please consider donating a small amount regularly.
I've put in a solution that may work, but it might have unintended side effects too.
I figure the best way to find out is to ship it and see: http://play.golang.org/p/JNHj3PtZaO
@dan should now work