Cucumber Expressions is an alternative to Regular Expressions with a more intuitive syntax, designed for defining step definitions in a human-readable format. This Python library provides the parsing and matching capabilities for these expressions. The current version is 19.0.0, and it maintains an active development status with regular updates, including recent Python-specific changes.
pip install cucumber-expressionsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create basic Cucumber Expressions using built-in parameter types like `{int}` and how to define and register your own custom parameter types (`{color}` in this example) to extend the expression matching capabilities. It shows how to initialize `Expression` objects with a `ParameterTypeRegistry` and use the `match` method to extract values.
Upgrade Python to version 3.10 or higher.
Use either pure Cucumber Expression syntax or pure Regular Expression syntax (if supported by your test runner, like `behave`), but do not combine them in one expression string parsed by this library.
If you need to extract values, define them as a parameter type (e.g., `{word}` or `{string}`). If a part of the text is optional, simply enclose it in parentheses.Escape special characters `(`, `{`, `\` with a preceding backslash. Consider raw strings (`r'...'`) or double backslashes in Python string literals to simplify escaping.Ensure no whitespace exists immediately before or after the `/` character when defining alternative text within a Cucumber Expression (e.g., `I have {int} cucumber(s) in my belly/tummy`).No dependency data recorded yet.