gsub() function in
R Language is used to replace all the matches of a pattern from a string. If the pattern is not found the string will be returned as it is.
Syntax:
gsub(pattern, replacement, string, ignore.case=TRUE/FALSE)
Parameters:
pattern: string to be matched
replacement: string for replacement
string: String or String vector
ignore.case: Boolean value for case-sensitive replacement
Example 1:
Output:
[1] "Goodsforgoods"
[1] "GeeksforBooks"
[1] "BooksforBooks"
Example 2:
Output:
[1] "R Tutorial" "Java example" "Go-Lang Tutorial"
[1] "R Tutorial" "Java Tutorial" "Go-Lang Tutorial"