Backreferences {rebus.base} | R Documentation |
Backreferences
Description
Backreferences for replacement operations. These are used by replacement
functions such as sub
and
stri_replace_first_regex
, and by the stringi
and stringr
match functions such as
stri_match_first_regex
.
Usage
REF1
REF2
REF3
REF4
REF5
REF6
REF7
REF8
REF9
ICU_REF1
ICU_REF2
ICU_REF3
ICU_REF4
ICU_REF5
ICU_REF6
ICU_REF7
ICU_REF8
ICU_REF9
Format
An object of class regex
(inherits from character
) of length 1.
References
http://www.regular-expressions.info/backref.html and http://www.rexegg.com/regex-capture.html
See Also
capture
, for creating capture groups that can be
referred to.
Examples
# For R's PCRE and Perl engines
REF1
REF2
# and so on, up to
REF9
# For stringi/stringr's ICU engine
ICU_REF1
ICU_REF2
# and so on, up to
ICU_REF9
# Usage
sub("a(b)c(d)", REF1 %R% REF2, "abcd")
stringi::stri_replace_first_regex("abcd", "a(b)c(d)", ICU_REF1 %R% ICU_REF2)
[Package rebus.base version 0.0-3 Index]