A hack to use PEP 634 to match regexps:
>>> from rematch import Re, Match, Group
>>> match Re("hello edk"):
...   case Match(r"hello (.*)", Group(whom)):
...     print(f"Greetings, {whom}!")
...   case Match(r"goodbye (.*)", Group(whom)):
...     print(f"Sorry to see you go, {whom}!")
...
Greetings, edk!Sub is also available, with sed-ish "match if there were any substitutions"
semantics:
>>> from rematch import Re, Sub, Text
>>> match Re("hello edk"):
...   case Sub(r"hello", "goodbye", Text(s)):
...     print(s)
...
goodbye edkYou can also save the number of substitutions in n with Num(n).