我正在尝试使用R
包RefManageR
来管理参考书目,如下所示。
library(RefManageR)
file.name <- system.file("Bib", "RJC.bib", package="RefManageR")
bib <- ReadBib(file.name)
BibOptions(check.entries = FALSE, bib.style = "authoryear", max.names = 1,
style = "citation", bibpunct = c("(",")","(",")",";",","))
Cite(bib, c("jennings2013bayesian", "ritchie2012novel"))
[1] "(Jennings, et al., 2013; Ritchie, et al., 2012)"
如何调整引文中的标点符号以获得以下所需引用(之前没有逗号)?
[1] "(Jennings et al., 2013; Ritchie et al., 2012)"
bibpunct
参数似乎没有可用的选项。
答案 0 :(得分:1)
您可以使用这样的简单正则表达式:
, (?=et al\.)
# match a comma, only when it is followed by et al.
然后需要用一个空格替换,请参阅a demo on regex101.com。
<小时/> 在R
:
ref <- c("(Jennings, et al., 2013; Ritchie, et al., 2012)")
(ref <- gsub(", (?=et al\\.)", " ", ref, perl=TRUE))
<小时/> 这产生了
[1] "(Jennings et al., 2013; Ritchie et al., 2012)"