Reputation: 1460
For instance:
a = '[122][md]+'
b = '[3][md+5]x'
I want to remove the first bracket and the contents in this bracket, and get:
a = '[md]+'
b= '[md+5]x'
Upvotes: 0
Views: 42
Reputation: 520928
Use sub
with the pattern \[.*?\]
and replace that with empty string.
a <- '[122][md]+'
b <- '[3][md+5]x'
sub("\\[.*?\\]", "", a)
sub("\\[.*?\\]", "", b
Upvotes: 1