pregex.core.operators
This module contains various classes representing operators that are typically applied between two or more patterns.
Classes & methods
Below are listed all classes within pregex.core.operators
along with any possible methods they may possess.
- class pregex.core.operators.Concat(*pres: Union[Pregex, str])[source]
Matches the concatenation of the provided patterns.
- Parameters
*pres (Pregex | str) – Two or more patterns that are to be concatenated.
- Raises
NotEnoughArgumentsException – Less than two arguments are provided.
InvalidArgumentTypeException – At least one of the provided arguments is neither a
Pregex
instance nor a string.
- Note
If no arguments are provided, then the resulting
Pregex
instance corresponds to the “empty string” pattern, whereas if a single argument is provided, it is simply returned wrapped within aPregex
instance.
- class pregex.core.operators.Either(*pres: Union[Pregex, str])[source]
Matches either one of the provided patterns.
- Parameters
*pres (Pregex | str) – Two or more patterns that constitute the operator’s alternatives.
- Raises
NotEnoughArgumentsException – Less than two arguments are provided.
InvalidArgumentTypeException – At least one of the provided arguments is neither a
Pregex
instance nor a string.
- Note
If no arguments are provided, then the resulting
Pregex
instance corresponds to the “empty string” pattern, whereas if a single argument is provided, it is simply returned wrapped within aPregex
instance.One should be aware that
Either
is eager, meaning that the regex engine will stop the moment it matches either one of the alternatives, starting from the left-most pattern and continuing on to the right until a match occurs.
- class pregex.core.operators.Enclose(pre: Union[Pregex, str], *enclosing: Union[Pregex, str])[source]
Matches the pattern that results from concatenating the
enclosing
pattern(s) to both sides of patternpre
.- Parameters
- Raises
NotEnoughArgumentsException – Less than two arguments are provided.
InvalidArgumentTypeException – Either
pre
or at least one of theenclosing
patterns is neither aPregex
instance nor a string.