Regular Expression
RegEx Functions
Action
Function
Inputs:
#Search for substring in a string
y <- c("carrot", "apple", "banana", "carrot")
grep("carrot", y)
#Replace a single value within a string
sub("r”, “R”, y)
#Replace all instances within a string
gsub(“r”, “R”, y)
#Find matches of exact strings
grepl("car", y)Outputs:
Resources
Last updated
