Wrap a word in word boundary (\\b) characters. Useful when combined with stringr::str_which() and stringr::str_detect() to match only entire words and not that word inside another word (e.g., "sting" and "testing").

rx_break(pattern)

Arguments

pattern

A regex pattern (a word) to wrap in \\b.

Value

The a glue vector of pattern wrapped in \\b.

Examples

rx_break("test")
#> \btest\b
rx_break(state.abb[1:5])
#> \bAL\b
#> \bAK\b
#> \bAZ\b
#> \bAR\b
#> \bCA\b