mgsub {mgsub}R Documentation

Safe, multiple gsub

Description

mgsub - A safe, simultaneous, multiple global string replacement wrapper that allows access to multiple methods of specifying matches and replacements.

mgsub_dict - Dictionary version of mgsub that takes a vector of replacement strings, named with their matching search terms and applies them to a single string to be modified.

Usage

mgsub(string, pattern, replacement, recycle = FALSE, conversions = list(),
  ...)

mgsub_dict(string, conversions = list(), ...)

Arguments

string

a character vector where replacements are sought

pattern

Character string to be matched in the given character vector

replacement

Character string equal in length to pattern or of length one which are a replacement for matched pattern.

recycle

logical. should replacement be recycled if lengths differ?

conversions

DEPRECATED - will be removed in a later release

...

arguments to pass to regexpr / sub

Value

Converted string.

Examples

mgsub("hey, ho",list("hey"="ho","ho"="hey"))
mgsub("developer",list("e" ="p", "p" = "e"))
mgsub("The chemical Dopaziamine is fake",
      list("dopa(.*?) "="mega\\1 ","fake"="real"),
      ignore.case=TRUE)

[Package mgsub version 1.5.0 Index]