不确定如何在R中实现它,
.*(?<!See) (item 7 .*)
工作
sub
,只需注意see后面的空格和可以忽略的字母大小写
ignore.case
参数
sub(".*(?<!See) (item 7 .*)", "\\1", s, ignore.case = T, perl = T)
# [1] "Item 7 Management's Discussion and Analysis. BlahBlahBlah. Item 8 Financial Statements and Supplementary Data."
另一种选择:
sub(".*(?=(?<!See) ?item 7)", "", s, ignore.case = T, perl = T)
# [1] "Item 7 Management's Discussion and Analysis. BlahBlahBlah. Item 8 Financial Statements and Supplementary Data."
具有
str_extract_all()
从…起
stringr
包,它似乎没有提供
忽略.case
选项,您可以使用
[Ii]
要忽略此情况:
library(stringr)
str_extract_all(s, "(?<!See )[Ii]tem 7(.*)")
# [1] "Item 7 Management's Discussion and Analysis. BlahBlahBlah. Item 8 Financial Statements and Supplementary Data."