mirror of
https://github.com/mickael-menu/zk
synced 2024-11-15 12:12:56 +00:00
50855154e2
* Move everything under the internal package. * Better separation between core and adapter packages, for easier unit testing. * Simplify data models. * Support multiple opened notebooks during runtime (useful for the LSP server). * Proper surface API which might be exposed later as a public Go package.
20 lines
403 B
Go
20 lines
403 B
Go
package icu
|
|
|
|
// EscapePattern adds backslash escapes to protect any characters that would
|
|
// match as ICU pattern metacharacters.
|
|
//
|
|
// http://userguide.icu-project.org/strings/regexp
|
|
func EscapePattern(s string) string {
|
|
out := ""
|
|
|
|
for _, c := range s {
|
|
switch c {
|
|
case '\\', '.', '^', '$', '(', ')', '[', ']', '{', '}', '|', '*', '+', '?':
|
|
out += `\`
|
|
}
|
|
out += string(c)
|
|
}
|
|
|
|
return out
|
|
}
|