Skip to content

edk0/rematch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rematch

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 edk

You can also save the number of substitutions in n with Num(n).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages