我希望使用正则表达式的查找和替换功能,将以下文本:
"some text i dont care about \cite[p. 6]{some-bibtex-citation}
some more text I care even less about \cite[p. 321 / 4]{and-another-citation-from-bibxtex} and still more text."
转换为:
"some text i dont care about [\citem{author}{some-bibtex-citation}, p. 6]
some more text I care even less about [\citem{author}{and-another-citation-from-bibxtex}, p. 321 / 4]
and still more text."
可以看出,所有的\cite都被替换成了一个不同的字符串。它们现在被括在方括号中,并且它们都以[citem {author}开头。
我尝试使用以下查找正则表达式,基本上是有效的,但有时会选择太多文本:
\\cite\[(.+)\]\{(.+)\}
我用于替换的正则表达式是:
[\\citem{author}{\2}, \1]