作者:猛儿187888 | 来源:互联网 | 2023-05-18 22:30
Iwanttousesearch&replacewitharegularexpressiontoturnthefollowingtext:我想用搜索和替换的正则
I want to use search & replace with a regular expression to turn the following text:
我想用搜索和替换的正则表达式来转换下面的文本:
"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-bibtex-citation}一些我更不关心的文本,\cite[p]。{和另一个-引用-来自-bibxtex}和更多的文本"
into this:
到这个:
"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."
“一些我不关心的文本[\项目{author}{some-bibtex-citation}, p. 6]一些我更不关心的文本[\项目{author}{and another- cit- from-bibxtex}, p. 321 / 4],还有更多的文本。”
As you can see, all of the \cite occurences have been replaced with a different one. They are now surrounded by [ and ] and they all start with [citem{author}
如您所见,所有引用的出现都被替换为另一个。它们现在被[和]包围,它们都从[citem{author}
I tried it with the following search regex which basically works but can select too much text all at once:
我尝试了下面的搜索regex,它基本上可以工作,但可以同时选择太多的文本:
\\cite\[(.+)\]\{(.+)\}
The replace regex I used for this is:
我使用的替代regex是:
[\\citem{author}{\2}, \1]
1 个解决方案