regexps is a simple package for common regexp patterns and a caching regexp compilation system.
> go get github.com/go-corelibs/regexps@latestfunc main() {
var err error
var rx *regexp.Regexp
// this first call tries to compile the broken pattern
rx, err = regexps.Compile(`[not a thing`)
// this second call just returns the prior results for
// the same broken pattern
rx, err = regexps.Compile(`[not a thing`)
// this next call actually compiles a regexp instance
rx, err = regexps.Compile(`[not] a thing`)
// trying the same pattern again just returns the prior
// instance
rx, err = regexps.Compile(`[not] a thing`)
// in case clearing the cached results is necessary...
regexps.ClearCache()
}Go-CoreLibs is a repository of shared code between the Go-Curses and Go-Enjin projects.
Copyright 2023 The Go-CoreLibs Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use file except in compliance with the License.
You may obtain a copy of the license at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.