How to remove special strings

How can I remove "
from this
" " Indeed it all thanks..... "

Hi @Ayomide
Not sure how your data looks like, but you generally can't have more than two quotes of the same type in a string (single or double), read more here ...

So I wrote your string with the two options below.

library(tidyverse)
#you can't have more than 2 double quotes in a character object
#option one: use escape (\") to get a literal double quote
string <- " \" Indeed it all thanks..... "
#option two: wrap your expression in two single quotes if text contains double quotes
string <- ' " Indeed it all thanks..... '
#then remove all double quotes
string %>% 
  str_remove_all('\"') %>% 
  str_squish() #this one is to remove leading, trailing and interword spaces

Hope it helps

Thanks, this solved it for me.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.