A regular expression is a concise pattern notation for matching scenario text and extracting parameter values in Cucumber step definitions. It can make steps flexible and reusable, but complex patterns are difficult to understand. section 8.4.4
Use regular expressions to:
- Capture arbitrary text with `(.*)` or require at least one character with `(.+)`. section 8.4.4
- Restrict values with digit patterns, exact lengths, alternatives, optional characters, and non-capturing groups. section 8.4.4
- Match parameters directly inside step definitions, including statuses, names, and point totals. section 8.4.4
Matching a frequent-flyer step
The pattern `^Tara is a (.*) Frequent Flyer member with (\\d+) points` captures the member status and requires a sequence of digits for the points value.
Constraining values
Alternatives such as `(Standard|Bronze|Silver|Gold)` accept only known statuses, while `s?he` accepts either “she” or “he.”
Table 8.2 Common regular expressions used in Cucumber scenarios (view table figure)
Browse common Cucumber regular-expression forms with their meanings and matching examples. section 8.4.4


























