I have the following string in R:
string1 = "A((..A>B)A"
I would like to remove all punctation, and the letter immediately after >
, i.e. >B
Here is the output I desire:
output = "AAA"
I tried using gsub()
as follows:
output = gsub("[[:punct:]]","", string1)
But this gives AABA
, which keeps the immediately following character.
This would work using your work plus a leading lookbehind first to look for what comes after the >
character.
gsub('(?<=>).|[[:punct:]]', '', "A((..A>B)A", perl=TRUE)
## [1] "AAA"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With