Reputation: 105
I have :
String=“text(2019),text1(2015),text2(Napoli 2018) . Text5(Milan 2019)
Desidered output:
text,text1,text2(Napoli 2018). Text5(Milan 2019)
Then, I want delete only (2019) , (2015) and not (Napoli 2018 ) and (Milan 2019)
Thanks !
Upvotes: 0
Views: 291
Reputation: 18357
Replace \(\d+\)
with empty string.
data <- c("text(2019),text1(2015),text2(Napoli 2018) . Text5(Milan 2019)")
gsub("\\(\\d+\\)", "", data)
Prints,
[1] "text,text1,text2(Napoli 2018) . Text5(Milan 2019)"
Upvotes: 2