Compile Cucumber Expressions and plain Regex patterns to Elixir regexes.
Cucumber Expression syntax: {int} → -?\d+ {float} → -?\d*.\d+ {string} → "..." or '...' {word} → [^\s]+ {paramtype} → looked up in ParameterType registry (optional) → optional group a/b → alternation
Summary
Types
@type match() :: %{args: list(), param_types: [Cucumberex.ParameterType.t()]}
Functions
Compile a Cucumber Expression string or Regex to an internal match pattern.
The param_type_registry pid is required for Cucumber Expressions containing
{custom_type} parameters; plain strings and regexes don't need it.
Examples
iex> {:regex, _} = Cucumberex.StepDefinition.Expression.compile(~r/^foo$/)
iex> {kind, _} = Cucumberex.StepDefinition.Expression.compile("^raw regex$", nil)
iex> kind
:regex
Match step text against a pattern, returning %{args: [...]} or nil.
Examples
iex> Cucumberex.StepDefinition.Expression.match(~r/^hello (\w+)$/, "hello world", nil)
%{args: ["world"], param_types: []}
iex> Cucumberex.StepDefinition.Expression.match(~r/^nope$/, "hello", nil)
nil