Truncate the string in R
I am trying to extract part of a string in R. The strings are shaped ABC_constantStuff_ABC_randomStuff
and ABC
is what I am trying to extract. ABC
unknown and can be 1-3 characters long. I tried grep
and gsub
but don't know how to specify my regex using
str <- 'GDP\" title=\"GDP - News\"></a>"'
symbol <- gsub(pattern,'',str)
It is GDP
unknown here and can be 1-3 characters long, \" title=\"
is constant in every line and I would like to remove\" title=\"GDP - News\"></a>"
Thank you for your help.
source to share