Anchors: The start or end of a string.

Description Usage Arguments Format Value Note References See Also Examples

Description

START matches the start of a string. END matches the end of a string. exactly makes the regular expression match the whole string, from start to end.

Usage

1
2
3
4
5

Arguments

x

A character vector.

Format

An object of class regex (inherits from character) of length 1.

Value

A character vector representing part or all of a regular expression.

Note

Caret and dollar are used as start/end delimiters, since \A and \Z are not supported by R's internal PRCE engine or stringi's ICU engine.

References

http://www.regular-expressions.info/anchors.html and http://www.rexegg.com/regex-anchors.html

See Also

whole_word and modify_mode

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
START
END

# Usage
x <- c("catfish", "tomcat", "cat")
(rx_start <- START %R% "cat")
(rx_end <- "cat" %R% END)
(rx_exact <- exactly("cat"))
stringi::stri_detect_regex(x, rx_start)
stringi::stri_detect_regex(x, rx_end)
stringi::stri_detect_regex(x, rx_exact)

Example output

<regex> ^
<regex> $
<regex> ^cat
<regex> cat$
<regex> ^cat$
[1]  TRUE FALSE  TRUE
[1] FALSE  TRUE  TRUE
[1] FALSE FALSE  TRUE

rebus.base documentation built on May 2, 2019, 5:14 a.m.