diff options
author | EuAndreh <eu@euandre.org> | 2024-12-10 12:29:03 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-12-10 12:29:03 -0300 |
commit | 8359c047aaebe274a2d811d61922b571ca7d10df (patch) | |
tree | 070e0ed93d27a842776ada805eeb4270e7e3c806 /src/urubu/spec/grammar/util.go | |
parent | Start building test files (diff) | |
download | cotia-8359c047aaebe274a2d811d61922b571ca7d10df.tar.gz cotia-8359c047aaebe274a2d811d61922b571ca7d10df.tar.xz |
Namespace packages with "urubu/"
Diffstat (limited to 'src/urubu/spec/grammar/util.go')
-rw-r--r-- | src/urubu/spec/grammar/util.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/urubu/spec/grammar/util.go b/src/urubu/spec/grammar/util.go new file mode 100644 index 0000000..bf3f233 --- /dev/null +++ b/src/urubu/spec/grammar/util.go @@ -0,0 +1,21 @@ +package grammar + +import "strings" + +var rep = strings.NewReplacer( + `.`, `\.`, + `*`, `\*`, + `+`, `\+`, + `?`, `\?`, + `|`, `\|`, + `(`, `\(`, + `)`, `\)`, + `[`, `\[`, + `\`, `\\`, +) + +// EscapePattern escapes the special characters. +// For example, EscapePattern(`+`) returns `\+`. +func EscapePattern(s string) string { + return rep.Replace(s) +} |