R Regex: removing only the immediate following character after >

Viewed 87

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.

3 Answers
Related