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

Regex utility function for returning all regex matches #138

Open
dbarnett opened this issue Mar 23, 2015 · 0 comments
Open

Regex utility function for returning all regex matches #138

dbarnett opened this issue Mar 23, 2015 · 0 comments

Comments

@dbarnett
Copy link
Contributor

If you want to perform a regex search in a string as with match(), there doesn't seem to be any way to get all matches at once except for awkwardly looping through count values and repeatedly calling match().

We should create a utility function that will take a regex and return all matches, similar to python's re.findall. Each match will have a few properties you might want to know (start, end, capture groups), so it makes sense to return a dict for each, something like:

echo maktaba#re#FindAll('foobarbaz', '[aeiou]\+')

[{'start': 1, 'end': 2, 'groups': []}, {'start': 4, 'end': 4, 'groups': []}, {'start': 7, 'end': 7, 'groups': []}]

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

No branches or pull requests

1 participant