Learn R Programming

RVerbalExpressions (version 0.1.1)

rx_word_edge: Find beginning or end of a word.

Description

Match beginning or end of a word—a string consisting of of word characters (a–z, A–Z, 0–9 or _).

Usage

rx_word_edge(.data = NULL)

Arguments

.data

Expression to append, typically pulled from the pipe %>%

Examples

Run this code
rx_word_edge()

x <- rx() %>%
 rx_word_edge() %>%
 rx_alpha() %>%
 rx_one_or_more() %>%
 rx_word_edge()

# create inputs
string1 <- "foobar"
string2 <- "foo 23a bar"

# matches 'foobar'
regmatches(string1, regexpr(x, string1))
# matches 'foo' and 'bar' separately
regmatches(string2, gregexpr(x, string2))

Run the code above in your browser using DataLab