unlist(lapply(unlist(strsplit(a, ",")), function(x) eval(parse(text = x))))
# [1] 1 2 3 4 20 21 22 23 24 25 30 31 32 33 34 35 36 37 38 39 40
And here'a another approach in base R that does not use eval(parse())
unlist(lapply(strsplit(x = a, split = ","), function(x){
unlist(lapply(strsplit(x = x, split = ":"), function(y)
as.numeric(y[1]):as.numeric(y[2])))
}))
# [1] 1 2 3 4 20 21 22 23 24 25 30 31 32 33 34 35 36 37 38 39 40