File size: 409 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
package search
import "strings"
// We need to escape any characters that have meaning for `ILIKE` in Postgres.
// https://www.postgresql.org/docs/8.3/static/functions-matching.html
var escapeRep = strings.NewReplacer(`\`, `\\`, `%`, `\%`, `_`, `\_`)
// Escape will escape a search string for use with the Postgres `like` and `ilike` operators.
func Escape(s string) string {
return escapeRep.Replace(s)
}
|