How to get words that end with specific characters inside each string r
I have a vector of strings that looks like this:
str <- c("bills slashed for poor families today", "your calls are charged", "complaints dept awaiting refund")
I want to get all words that end with a letter s
and delete s
. I tried:
gsub("s$","",str)
but it doesn't work because it tries to match lines ending with s
instead of words. I am trying to get output that looks like this:
[1] bill slashed for poor familie today
[2] your call are charged
[3] complaint dept awaiting refund
Any guidance on how I can do this? Thanks to
+3
source to share
3 answers