Reputation: 403
I have a string and I want to check if it is ending with "(n)" where n is any natural number and quotes are not included. an example of this is
"320_50iz_toSTORE(29)"
I am trying grep
> grep("$([:digit:])",E)
integer(0)
Further, I want to replace the match(if found) with empty string. so "320_50iz_toSTORE(29)"
should go to "320_50iz_toSTORE"
Upvotes: 0
Views: 54
Reputation: 886948
Here is one option
sub("[(][0-9]+[)]$", "", "320_50iz_toSTORE(29)")
#[1] "320_50iz_toSTORE"
Upvotes: 2