Skip to main content
2 of 4
deleted 77 characters in body
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

Red, 136 123 bytes

func[s][a: charset"<>"until[parse s[any[[change["("t: a"<"a")"](t/1)]|[change["("a">"t: a")"](t/1)]| skip]]2 > length? s]s]

Try it online!

More readable:

f: func[s][
    a: charset "<>"
    l: [change["(" t: a "<" a ")"](t/1)]
    r: [change["(" a ">" t: a ")"](t/1)]
    until [
        parse s[any [l | r | skip]] 
        single? s    
    ]
    s
]
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61