Categorygithub.com/jille/deregexp
repositorypackage
1.0.0
Repository: https://github.com/jille/deregexp.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Deregexp

GoDoc Build Status

Deregexp converts a regexp to an expression with substring matches. This expression does not express exactly the same as the regexp, but a superset. It can be used for a cheap first pass filter, or for index lookups.

Examples

$ go run cmd/test/test.go "Mary.+had.+a.+little.+(lamb|sheep)"
"little" AND "Mary" AND "had" AND ("sheep" OR "lamb")

Note that the "a" has been dropped because it is implied by "Mary" and "had".

$ go run cmd/test/test.go "Mary.+had.+(a|no).+little.+(lamb|sheep)"
"little" AND "Mary" AND "had" AND ("sheep" OR "lamb")

Note that the "(a|no)" has been dropped because the "a" is implied by "Mary" and "had", and (TRUE OR "no") is always true.

Known limitations

Case insensitivity is not supported. You can of course use the resulting expression case insensitively, but controlling case sensitivity with (?i) is not supported. Patches are welcome.