Adds \b to both sides of the pattern. This ensures that the pattern is matched as a whole word (not inside another word).

xp_wrap_boundary(pattern)

Arguments

pattern

A regexpert object or character string from the pipe.

Value

A regexpert object.

Examples

# Match "cat" but not "category" or "bobcat"
xp_build_literal("cat") %>% xp_wrap_boundary()
#> <regexpert pattern>
#>   \bcat\b