Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ReplacementCase

Force the case of replacement values


Description

Forces replacement values to be upper or lower case. Only supported by Perl regular expressions.

Usage

as_lower(x)

as_upper(x)

Arguments

x

A character vector.

Value

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

References

Examples

# Convert to title case using Perl regex
x <- "In caSE of DISASTER, PuLl tHe CoRd"
matching_rx <- capture(WRD) %R% capture(wrd(1, Inf))
replacement_rx <- as_upper(REF1) %R% as_lower(REF2)
gsub(matching_rx, replacement_rx, x, perl = TRUE)

# PCRE and ICU do not currently support this operation
# The next lines are intended to return gibberish
gsub(matching_rx, replacement_rx, x)
replacement_rx_icu <- as_upper(ICU_REF1) %R% as_lower(ICU_REF2)
stringi::stri_replace_all_regex(x, matching_rx, replacement_rx_icu)

rebus.base

Core Functionality for the 'rebus' Package

v0.0-3
Unlimited
Authors
Richard Cotton [aut, cre]
Initial release
2017-04-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.