# NOT RUN {
name_rex <- paste0(
"(?<first>[[:upper:]][[:lower:]]+) ",
"(?<last>[[:upper:]][[:lower:]]+)"
)
notables <- c(
" Ben Franklin and Jefferson Davis",
"\tMillard Fillmore"
)
# All occurrences
allpos <- re_exec_all(notables, name_rex)
allpos
# Custom $ to extract matches and positions
allpos$first$match
allpos$first$start
allpos$first$end
# }
Run the code above in your browser using DataCamp Workspace