Try it. It extracts the portion of the string that matches the portion of the regular expression surrounded by parentheses, and then simplifies it with unique:
library(gsubfn)
strapplyc(string, "<([^>]*)>", simplify = unique)
giving:
[1] "FIELD1" "FIELD2" "FIELD3"
REVISED slight simplification.
source
share