Suppose you want to reverse a string that parts sectioned off by parentheses and parts that aren't. What would be the best possible regex method to approach this? Here is a link to my last question addressing a similar issue R regex - splitting between parentheses
x <- "(A|C|T)AG(C|T)(A|C|G|T)(A|C|G|T)(A|C|G|T)(A|C|G|T)(A|C|G|T)GCC(C|T)(A|C|G|T)(A|C|G|T)(A|C|G)"
# Desired output
rev_x
"(A|C|G)(A|C|G|T)(A|C|G|T)(C|T)CCG(A|C|G|T)(A|C|G|T)(A|C|G|T)(A|C|G|T)(A|C|G|T)(C|T)GA(A|C|T)"