Shortcuts¶
As everyone is lazy and there is some things that are very boring to do while very easy to transform into a shortcut, here’s the dedicated module.
Everything can be done directly with the nsre.ast
module but it’s
shorter with a shortcut.
-
nsre.shortcuts.
seq
(s: Sequence) → nsre.ast.Node¶ Converts a sequence of items into concatenated Eq matchers. Useful to match a string exactly.
>>> from nsre import * >>> re = RegExp.from_ast(seq('foo')) >>> assert re.match('foo') >>> assert not re.match('bar')
- Parameters
s – Sequence to convert into AST
-
nsre.shortcuts.
anything
() → nsre.ast.Node¶ Matches anything. Conceptual equivalent of “.*” in regular regular expressions.