我有一个引用列表,例如,
references <- c(
"Dumitru, T.A., Smith, D., Chang, E.Z., and Graham, S.A., 2001, Uplift, exhumation, and deformation in the Japanese Mt Everest, Paleozoic and Mesozoic tectonic evolution of central Africa: from continental assembly to intracontinental deformation: Journal of Neverland, v. 3, no. 192, p. 71-199.",
"Dumitru, T.A., Smith, D., Chang, E.Z., and Graham, S.A., 2001, Uplift, exhumation, and deformation in the Japanese Mt Everest, Paleozoic and Mesozoic tectonic evolution of central Africa: from continental assembly to intracontinental deformation: Journal of Neverland, no. 3.",
"Dumitru, T.A., Smith, D., Chang, E.Z., and Graham, S.A., 2001, Uplift, exhumation, and deformation in the Japanese Mt Everest, Paleozoic and Mesozoic tectonic evolution of central Africa: from continental assembly to intracontinental deformation: Journal of Neverland, p. 71-199."
)
我试过
(?<=:)(?.*)(?=(v\.)|(no\.)|(p\.))
但正则表达式返回“从大陆组装到大陆变形:梦幻岛杂志,第 3 卷,没有。第 192 页不是我打算提取的。(?<=:)(?:[^:].*?)(?=(, v\.)|(, no\.)|(, p\.))
我期待的是“梦幻岛杂志”,但回归是“从大陆组装到大陆内变形:梦幻岛杂志”
最佳答案
在这里,我们只是将最后一个冒号之前的文本匹配到捕获组中的下一个逗号
stringr::str_match(references, ": ((?!:)[^,:]*),")[,2]
# [1] "Journal of Neverland" "Journal of Neverland" "Journal of Neverland"
关于r - 如何将引用列表转换为数据框?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56245545/