replaceStr: Replace Substring in a Given String

View source: R/utilsFiles.R

replaceStrR Documentation

Replace Substring in a Given String

Description

This function replaces occurrences of a given substring (pattern) in a text (intext) with a new substring (replacement). You can also specify if you want to replace only whole words and whether to ignore case.

Usage

replaceStr(pattern, replacement, intext, word = FALSE, ignore.case = TRUE)

Arguments

pattern

The substring that you want to replace.

replacement

The new substring that will replace pattern.

intext

The input text where you want to replace the substring.

word

Logical, if TRUE only whole words will be replaced.

ignore.case

Logical, if TRUE the function ignores case.

Value

A string with the replaced substrings.

Examples

replaceStr( "world", "everyone","Hello world")
replaceStr("WORLD", "everyone","Hello world",  ignore.case = TRUE)
replaceStr( "world", "everyone","Hello world", word = TRUE)

Epiconcept-Paris/STRAP-epiuf documentation built on Aug. 5, 2024, 3:41 a.m.