simplematch icon indicating copy to clipboard operation
simplematch copied to clipboard

Development direction

Open mikaelho opened this issue 2 years ago • 2 comments

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 to match

mikaelho avatar Sep 22 '22 14:09 mikaelho

Hi, yes it‘s in development. I‘m on vacation in the moment, I‘ll look into this next week ☀️

tfeldmann avatar Sep 22 '22 18:09 tfeldmann

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:

  1. + (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.
  2. Unnamed groups can be typed: {:int}
  3. 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 the unnamed list are always there, even if potentially empty.
  4. As an alternative to match, added a search method that returns a list of match dicts instead of the single dict.
  5. 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.

mikaelho avatar Sep 23 '22 04:09 mikaelho