Skip to content
/ deregexp Public

Deregexp deconstructs a regexp to an expression with substring filters.

License

Notifications You must be signed in to change notification settings

Jille/deregexp

Repository files navigation

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.

About

Deregexp deconstructs a regexp to an expression with substring filters.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages