【发布时间】:2019-10-08 06:38:07
【问题描述】:
我有一个参考列表,例如,
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 卷,第 3 期”。 192,页。不是我想要提取的。
(?<=:)(?:[^:].*?)(?=(, v\.)|(, no\.)|(, p\.))
我期待的是“梦幻岛日志”,但回归是“从大陆组装到大陆内变形:梦幻岛日志”
【问题讨论】:
-
等等,你是真的用
R,还是其他语言来做这个正则表达式? -
是的,我使用的是 R。所以实际上所有的 '\' 都应该是 '\\'
标签: r regex string regex-lookarounds regex-greedy