regex - Find a word in a string that starts with "PID" and return the word (in R) -


i need search large amount of strings find "word" starts pid. pid id tag, , they're numbered (pid1, pid23, etc.)

example of string search through: pid442 walks town

i need return specific id output "pid442." trying in r.

try this:

> library(gsubfn) > strapply(str, "\\bpid\\d+\\b", c, perl = true, simplify = true) [1] "pid442" "pid1"