Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework pattern matching to use glob-style patterns #171

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

melsabagh
Copy link
Contributor

BREAKING CHANGE: This PR changes the signature and behavior of the keys, values, and items methods of the Automaton class to process the optional pattern parameter as a Unix shell glob-style pattern.

Currently only the '?' (match any single character) and '*' (match zero or more characters) wildcards are supported (so no character classes nor ranges). The '\' character is reserved as the wildcard escape character (so any literal '\' in a pattern must itself be escaped as '\\\\' or r'\\').

The optional wildcard parameter is gone. The values for the optional how parameter can be one of MATCH_PREFIX (default; prefix match on keys) and MATCH_WHOLE (full match on keys).

BREAKING CHANGE: This commit changes the signature and behavior
of the Automaton keys, values, and items methods.

This commit changes the signatures of Automaton keys, values, and
items methods to the following:

- keys([pattern, [how]])
- values([pattern, [how]])
- items([pattern, [houw]])

This commit changes the behavior of these APIs to process patterns
as Unix shell-style glob patterns. The optional 'pattern' parameter
can contain one or more of the following wildcards anywhere in
the pattern:

- '?': matches any single character.
- '*': matches everything.

The '\\' character is reserved as the escape character. For example,
r'\\*' matches the literal '*' character. Each literal backslash must
be either expressed as '\\\\' or as a raw r'\\' string. For example,
r'\\t' matches '\\t'.

The optional 'how' argument is used to control how patterns are
matched using one of the following values:

- 'ahocorasick.MATCH_PREFIX' (default): Yield keys with prefixes that
  match the given pattern.
- 'ahocorasick.MATCH_WHOLE': Yield keys that fully match the given
  pattern.
@pombredanne
Copy link
Collaborator

@melsabagh-kw Let me review this in details... but I will not merge this in 2.0.0, rather this would be considered after since we had betas out and are about to release the final 2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants