I have a table with 153 rows by 9 columns. My interest is the character string in the first column, I want to extract the fourth word and create a new list from this fourth
We can use sub. We match the pattern one or more non-white space (\\S+) followed by one or more white space (\\s+) that gets repeated 3 times ({3}) followed by word that is captured in a group ((\\w+)) followed by one or more characters. We replace it by the second backreference.
sub("(\\S+\\s+){3}(\\w+).*", "\\2", str1)
#[1] "428" "353"
This selects by the nth word, so
sub("(\\S+\\s+){3}(\\w+).*", "\\2", str2)
#[1] "428" "353" "428"
Another option is stri_extract
library(stringi)
stri_extract_last_regex(str1, "\\w+")
#[1] "428" "353"
str1 <- c("Resistance_Test DevID (Ohms) 428", "Diode_Test SUBLo (V) 353")
str2 <- c(str1, "Resistance_Test DevID (Ohms) 428 something else")