I'm trying to split a string containing two entries and each entry has a specific format:
- Category (e.g.
active site/region) which is followed by a: - Term (e.g.
His, Glu/nucleotide-binding motif A) which is followed by a,
Here's the string that I want to split:
string <- "active site: His, Glu,region: nucleotide-binding motif A,"
This is what I have tried so far. Except for the two empty substrings, it produces the desired output.
unlist(str_extract_all(string, ".*?(?=,(?:\\w+|$))"))
[1] "active site: His, Glu" "" "region: nucleotide-binding motif A"
[4] ""
How do I get rid of the empty substrings?