fork(1) download
  1. xx <- c("abc-def]", "Radio Stations-Listened to Past Week-Toronto [FM-CFXJ-93.5 (93.5 The Move)]","Total Internet-Time Spent Online-Past 7 Days")
  2. pattern <- "\\[[^][]*](*SKIP)(*FAIL)|-"
  3. strsplit(xx, pattern, perl=TRUE)
  4.  
  5. pattern_recursive <- "(\\[(?:[^][]++|(?1))*])(*SKIP)(*FAIL)|-"
  6. xx2 <- c("Radio Stations-Listened to Past Week-Toronto [[F[M]]-CFXJ-93.5 (93.5 The Move)]","Total Internet-Time Spent Online-Past 7 Days")
  7. strsplit(xx2, pattern_recursive, perl=TRUE)
Success #stdin #stdout 0.16s 175424KB
stdin
Standard input is empty
stdout
[[1]]
[1] "abc"  "def]"

[[2]]
[1] "Radio Stations"                        
[2] "Listened to Past Week"                 
[3] "Toronto [FM-CFXJ-93.5 (93.5 The Move)]"

[[3]]
[1] "Total Internet"    "Time Spent Online" "Past 7 Days"      

[[1]]
[1] "Radio Stations"                            
[2] "Listened to Past Week"                     
[3] "Toronto [[F[M]]-CFXJ-93.5 (93.5 The Move)]"

[[2]]
[1] "Total Internet"    "Time Spent Online" "Past 7 Days"