word<-c("WB-5D-棕色","WB-5ER----黑","WB-ADC 哈哈哈","哦哦哦 WB-5CCC",
"300自然黑","3.45哈哈哈")
pattern<-'[a-zA-Z0-9]+-[a-zA-Z0-9]+|[0-9]+|[0-9]+.[0-9]+'
gregout<-gregexpr(pattern,word)
getcontent <- function(s,g){
substring(s,g,g+attr(g,'match.length')-1)
}
catch=0
for(i in 1:length(word)){
catch[i]<-getcontent(word[i],gregout[[i]])
}
机智如我自行解决,参考了 http://www.tuicool.com/articles/vEziEj