Некоторые мысли, не уверен, как они будут работать.
# somefile <- readLines("somefile.dat")
somefile <- c(
'MfB...[dbkey=CDS]"HEAT_2 :HEAT_2 :"',
'MfB...[dbkey=CDS]"NO_DOMAIN"'
)
gsub('^([^"]*).*', '\\1', somefile)
# [1] "MfB...[dbkey=CDS]" "MfB...[dbkey=CDS]"
gsub('^[^"]*"(.*)".*', '\\1', somefile)
# [1] "HEAT_2 :HEAT_2 :" "NO_DOMAIN"
splits <- strsplit(gsub('^[^"]*"(.*)".*', '\\1', somefile), "\\s*:\\s*")
splits
# [[1]]
# [1] "HEAT_2" "HEAT_2"
# [[2]]
# [1] "NO_DOMAIN"
dat <- do.call(rbind.data.frame,
c(lapply(splits, `length<-`, max(lengths(splits))),
list(stringsAsFactors = FALSE)))
names(dat) <- paste0("V", seq_along(dat))
dat$V0 <- gsub('^([^"]*).*', '\\1', somefile)
dat
# V1 V2 V0
# 1 HEAT_2 HEAT_2 MfB...[dbkey=CDS]
# 2 NO_DOMAIN <NA> MfB...[dbkey=CDS]