simplematch
simplematch copied to clipboard
Development direction
Hello. Is this package still in active development?
I have some ideas for further development, but I also understand that they will make simplematch clearly less simple. I am wondering if I should create PRs here, or if an independent fork might be more productive.
Some of the things on my mind:
- Support
+
and?
wildcards and|
for options - Support unnamed but typed groups
- Support
search
in addition tomatch
Hi, yes it‘s in development. I‘m on vacation in the moment, I‘ll look into this next week ☀️
Enjoy your vacation! ☀️🏝
For when you are back:
I must admit that in your absence I have experimented uncontrollably, and have now implemented some things, some of which can be turned into PRs depending on where you see this package going:
-
+
(any one character),?
(maybe one character) and|
(either, can be characters or groups). These can be escaped like this{+}
to match the literal "+" character. With this, you can express e.g. "1-3 characters" with+??
. More power could be added by combining these with groups, but have not tried that yet. - Unnamed groups can be typed:
{:int}
- Always return a tweaked dict that has the unnamed groups stored as a list in an attribute called
unnamed
instead of in the dict. This makes them easier to iterate over. The tweaked dict also defines itself as True or False based on whether there were matches, not based on if any groups were found, and there is no need to check for None because the object (as a dict) and theunnamed
list are always there, even if potentially empty. - As an alternative to
match
, added asearch
method that returns a list of match dicts instead of the single dict. - As a final insult, I experimented with using
[]
instead of{}
, because brackets are easier to write on a Nordic keyboard, look less cryptic in the pattern, and because they make it much easier to combine patterns with f-strings.