Adds an "either/or" condition to the pattern. This is equivalent to the regex pipe | operator.

xp_op_either(pattern, alternative)

Arguments

pattern

A regexpert object or character string from the pipe.

alternative

The alternative pattern or string to match.

Value

A regexpert object.

Examples

# Match "cat" or "dog"
xp_build_literal("cat") %>% xp_op_either("dog")
#> <regexpert pattern>
#>   (?:cat|dog)

# Match a digit or a letter
xp_build_digits() %>% xp_op_either(xp_build_letters())
#> <regexpert pattern>
#>   (?:\d|[A-Za-z])