I have a line in following format
IP1: IP2: 0.1,0.5,0.9
I split this line using following command:
myVector <- (strsplit(oneLine, \":\"))
You can use gregexpr and regmatchesto extract the numbers:
gregexpr
regmatches
as.numeric(unlist(regmatches(oneLine, gregexpr("-?\\d+\\.\\d+", oneLine)))) # [1] 0.1 0.5 0.9