library(stringr)
<- c( phones "Mia Smith, 728*971*9652", "Max Lee, 683*976*9876", "Ava Johnson, 912*254*3387")
str_remove(phones, pattern = "\\*")
Output:
[1] "Mia Smith, 728971*9652" "Max Lee, 683976*9876" "Ava Johnson, 912254*3387"
str_remove()
removes the first match in each string elementstr_remove_all()
removes all matches in each string elementstr_remove()
removes the first matched component in each input vector element. It is equivalent to str_replace()
with replacement by an empty quote.
library(stringr)
<- c( phones "Mia Smith, 728*971*9652", "Max Lee, 683*976*9876", "Ava Johnson, 912*254*3387")
str_remove(phones, pattern = "\\*")
Output:
[1] "Mia Smith, 728971*9652" "Max Lee, 683976*9876" "Ava Johnson, 912254*3387"
str_remove_all()
removes all the matches from each string element.
str_remove_all(phones, pattern = "\\*")
Output:
[1] "Mia Smith, 7289719652" "Max Lee, 6839769876" "Ava Johnson, 9122543387"