Another Way To Write Regular Expression.
myre
is a Python library that provides a way for human to create and use regular expressions.
pip install myre
Currently, there are two class to use, MatchAny
and MatchALL
.
Each pattern support four operation: &
|
^
-
.
For example, we have two patterns, patternA
and patternB
,
-
patternA | patternB
means we can matchpatternA
orpatternB
-
patternA & patternB
means we must matchpatternA
andpatternB
both -
patternA ^ patternB
means we can matchpatternA
but notpatternB
-
patternA - patternB
means after usingpatternB
to trim the origin string then we can matchpatternA
-
MatchAny
is used to match any of multiple patterns -
MatchALL
is used to match all of multiple patterns, if order is true, it will match these patterns in order
The detail could be found in tests/test_pattern