Skip to content

Instantly share code, notes, and snippets.

@dimiro1
Created April 13, 2016 20:03
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 dimiro1/c365974bb6366cd599babe7eaf455e71 to your computer and use it in GitHub Desktop.
Save dimiro1/c365974bb6366cd599babe7eaf455e71 to your computer and use it in GitHub Desktop.
func escapeQuery(s string) string {
s1 := regexp.QuoteMeta(s)
re := regexp.MustCompile("\\s+")
s1 = strings.TrimSpace(re.ReplaceAllString(s1, " "))
return s1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment