I’m hoping to pull full names out of the following pattern. Some names have hyphens or multiple caps as the examples given:
(all numbers inside parentheses are either 1 or 2 digits). All Capitalized city abbreviations before parentheses are either 2 or 3 chars long)
Davante Adams LV (6)
Christian McCaffrey CAR (10)
J.K. Dobbins BAL (5)
Amon-Ra St. Brown DET (7)
AJ Brown PHI (11)
Michael Pittman Jr. IND (14)
JuJu Smith-Schuster PIT (9)
Results should be…
Davante Adams
Christian McCaffrey
J.K. Dobbins
Amon-Ra St. Brown
AJ Brown
Michael Pittman Jr.
JuJu Smith-Schuster
>Solution :
Using strsplit
strsplit(str, " [A-Z]+ \\(\\d+\\) *")[[1]]
#> [1] "Davante Adams" "Christian McCaffrey" "J.K. Dobbins"
#> [4] "Amon-Ra St. Brown" "AJ Brown" "Michael Pittman Jr."
#> [7] "JuJu Smith-Schuster"
``