Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Using the dense dfa.

Patterns:

  • .+
  • a+

Input:

  • "aa"

Expected output:

  • PatternID(0) range 0-2
  • PatternID(1) range 0-2

My goal is to get all overlapping matches between patterns, but if from the same pattern then matches should report the longest match.

I'm currently using the method described here but this gets all overlapping matches including the shorter matches. Here's the fwd results:

HalfMatch { pattern: PatternID(0), offset: 1 }
HalfMatch { pattern: PatternID(1), offset: 1 }
HalfMatch { pattern: PatternID(0), offset: 2 }
HalfMatch { pattern: PatternID(1), offset: 2 }

Is there a better way of going about this? Other than:

  • Separate DFA per pattern, would be slower (there will be a larger number of patterns
  • Resorting to post-filtering to discard the smaller matches

@BurntSushi

You must be logged in to vote

No, this isn't supported. This crate doesn't even support non-overlapping leftmost-longest. The aho-corasick crate supports non-overlapping leftmost-longest, but not overlapping.

Replies: 1 comment

Comment options

No, this isn't supported. This crate doesn't even support non-overlapping leftmost-longest. The aho-corasick crate supports non-overlapping leftmost-longest, but not overlapping.

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.