Converts raw text into a safe regex pattern by escaping special characters.

xp_build_literal(pattern = NULL, literal = NULL)

Arguments

pattern

(Optional) An existing pattern from a pipe.

literal

The exact text/symbols you want to match.

Value

A regexpert object.

Examples

# Safely match a price with a dollar sign and decimal
xp_build_literal("$") %>% xp_build_digits() %>% xp_build_literal(".") %>% xp_build_digits()
#> <regexpert pattern>
#>   $\d.\d

# Starting a chain with a literal
xp_build_literal("v1.0") %>% xp_wrap_boundary()
#> <regexpert pattern>
#>   \bv1.0\b