You have two main options:
(1) grep for the numbers, and extract those.
(2) split on the comma, then coerce to numeric and check for NA
s
I prefer the second
splat <- strsplit(x, ",")[[1]]
numbs <- !is.na(suppressWarnings(as.numeric(splat)))
c(paste(splat[!numbs], collapse=","), splat[numbs])
# [1] "name1, name2 and name3" " 0" " 1" " 2"