str.replace: Replaces in str every occurence of pattern by replacement

View source: R/stringtools.R

str.replaceR Documentation

Replaces in str every occurence of pattern by replacement

Description

Replaces in str every occurence of pattern by replacement

Usage

## S3 method for class 'replace'
str(str, pattern, replacement, fixed = TRUE, perl = FALSE,
  ignore = NULL, ignore.pos = NULL, only.pos = NULL,
  ignore.pattern = "_IGNORE_", ...)

Arguments

str

the string to replaced

pattern

the substring to be replaced

replacment

the new substrings

Value

a string

Examples

## Not run: 
  str = c("12345678901234567890")
  pattern = c("34","12")
  replacement = c("AB","Holla die Waldfee")
  pos = cbind(1,10)
  str.replace(str,pattern,replacement, ignore.pos=pos)
  str.replace(str,pattern,replacement, only.pos=pos)
  str.replace(str,pattern,replacement)
  
  str = "int{5*2}*{2*3}"
  pattern = "int{_IGNORE_}"
  replacement = "integer{_IGNORE_}"  
  pos = cbind(c(5,11),c(7,13))
  str.replace(str,pattern,replacement, ignore.pos=pos)

## End(Not run)

skranz/stringtools documentation built on May 11, 2022, 4:48 a.m.