fork download
  1. x <- c("Total Assets in th USD", "Equity in mil EUR", "Number of Branches")
  2. currencies <- c("USD", "EUR", "GBP")
  3.  
  4. regex <- paste0("\\b(",
  5. paste(currencies, collapse = "|"),
  6. ")\\b")
  7. # results in
  8. # "\b(USD|EUR|GBP)\b"
  9.  
  10. matches <- regmatches(x, gregexpr(regex, x))
  11. res <- lapply(matches, function(x) if (length(x) == 0) NA else x)
  12. res[is.na(res)] <- ""
  13. unlist(res)
Success #stdin #stdout 0.23s 60768KB
stdin
Standard input is empty
stdout
[1] "USD" "EUR" ""