1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
lcds <- c()
blcds <- c()
#non upfront case
upfront <- grep("[0-9]+ *- *[0-9]+\\+500",x)
quotes <- x[upfront]
for(i in 1:length(quotes)){
matches <- gregexpr("[0-9]+ *- *[0-9]+\\+500",quotes[i])
row <- substring(quotes[i],matches[[1]],matches[[1]]+attr(matches[[1]],"match.length")-1)
row <- gsub("\\+500","",row)
row <- gsub(" ","",row)
lcds <- rbind(lcds,c(as.numeric(strsplit(row,"-")[[1]]),500,500))
blcds <- rbind(blcds,c(as.numeric(strsplit(row,"-")[[2]]),500,500))
}
quotes <- x[-upfront]
running <- grep("[0-9]+ *- *[0-9]+",quotes)
quotes <- quotes[running]
for(i in 1:length(quotes)){
matches <- gregexpr("[0-9]+ *- *[0-9]+",quotes[i])
row <- substring(quotes[i],matches[[1]],matches[[1]]+attr(matches[[1]],"match.length")-1)
row <- gsub("\\+500","",row)
row <- gsub(" ","",row)
lcds <- rbind(lcds,c(0,0,as.numeric(strsplit(row,"-")[[1]])))
blcds <- rbind(blcds,c(0,0,as.numeric(strsplit(row,"-")[[2]])))
}
|