fork download
  1. str <- "\n\n\n \n\n\n “Don't cry because it's over, smile because it happened.”\n\n Dr. Seuss\n\n\n\n\n \n tags:\n attributed-no-source,\n cry,\n crying,\n experience,\n happiness,\n joy,\n life,\n misattributed-dr-seuss,\n optimism,\n sadness,\n smile,\n smiling\n \n \n 176513 likes\n \n\n\n\n\nLike\n\n"
  2. reg <- "(?:\\G(?!\\A),?|tags:)\\R\\h*\\K[^\\s,]+"
  3. vals <- regmatches(str, gregexpr(reg, str, perl=TRUE))
  4. unlist(vals)
  5. ## cat(str, sep="\n")
Success #stdin #stdout 0.15s 175424KB
stdin
Standard input is empty
stdout
 [1] "attributed-no-source"   "cry"                    "crying"                
 [4] "experience"             "happiness"              "joy"                   
 [7] "life"                   "misattributed-dr-seuss" "optimism"              
[10] "sadness"                "smile"                  "smiling"