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

overlapping pattern #590

Closed
dongweigogo opened this issue Jul 2, 2019 · 5 comments
Closed

overlapping pattern #590

dongweigogo opened this issue Jul 2, 2019 · 5 comments
Labels

Comments

@dongweigogo
Copy link

dongweigogo commented Jul 2, 2019

Does this package support overlapping searching like finditer(patter, overlapped=True) in python package regex?

@BurntSushi
Copy link
Member

Please provide more detail. I don't see any support for overlapping matches in Python's regex library: https://docs.python.org/3/library/re.html Please provide links, and, ideally a code sample.

@dongweigogo
Copy link
Author

@BurntSushi Sorry for that, here is the link , and please refer:

‘Overlapped’ argument for regex.findall and regex.finditer
regex.findall and regex.finditer support an ‘overlapped’ flag which permits overlapped matches.

@BurntSushi
Copy link
Member

I asked you for a code sample so that I can understand what problem you're trying to solve. But you didn't give me one. As far as I can tell, strictly speaking, no, overlapping matches are not and will never be supported. However, some use cases may be aptly covered by RegexSet, which does permit overlapping matches to a degree.

@expenses
Copy link

Not sure if I should bump this but I have a use case for overlapping patterns. I'm writing a library for 2d pattern matching similar to what https://github.com/mxgmn/MarkovJunior does. This requires finding all overlapping patterns like \0\0. It's not very obvious how I should be doing this without overlapping patterns.

@BurntSushi
Copy link
Member

@expenses Code examples would help. If it's just literals like \0\0, then you should be able to use the aho-corasick crate.

If you do need overlapping regex matches, then some of the low level APIs in regex-automata support it. Feel free ask Discussion questions about it.

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

No branches or pull requests

3 participants