fork download
  1. library(stringr)
  2. string = "Speaks 2 times (1%) for a total of 34 words (1%)."
  3. unlist(str_extract_all(string, "[0-9]+"))[3]
  4. ## => [1] "34"
  5. sub("^(?:\\D+\\d+){2}\\D+(\\d+).*", "\\1", string)
  6. ## => "34"
Success #stdin #stdout 0.29s 42460KB
stdin
Standard input is empty
stdout
[1] "34"
[1] "34"