0
我有一些文本字符串,我想從中提取某些信息位。特別是我想從10中提取評分。R正則表達式提取等級從字符串中抽取10個
我想在構造函數func_to_extract_rating
,做以下的幫助...
text_string_vec <- c('blah$2.94 blah blah 3/10 blah blah.',
'foo foo 8/10.',
'10/10 bar bar21/09/2010 bar bar',
'jdsfs1/10djflks5/10.')
func_to_extract_rating <- function(){}
output <- lapply(text_string_vec,func_to_extract_rating)
output
[[1]]
[1] 3 10
[[2]]
[1] 8 10
[[3]]
[1] 10 10
[[4]]
[[4]][[1]]
[1] 1 10
[[4]][[2]]
[1] 5 10
'y < - regmatches(text_string_vec,gregexpr('\\ d +/10',text_string_vec)); rapply(y,strsplit,split ='/',how ='list')' – rawr