如何在记事本中找到两个字符之间的文本并将其替换为另外两个字符之间的文本?

时间:2019-12-26 13:21:20

标签: python notepad++

我有许多文件具有以下结构

    @article{mehri_buckling_2016,
    title = {Buckling and vibration},
    volume = {303},
    issn = {00457825},
    url = {https://linkinghub.elsevier.com/retrieve/pii/S004578251630010X},
    doi = {10.1016/j.cma.2016.01.017},
    pages = {75--100},
    journaltitle = {Computer Methods in Applied Mechanics and Engineering},
    shortjournal = {Computer Methods in Applied Mechanics and Engineering},
    author = {Mehri, M. and Asadi, H. and Wang, Q.},
    urldate = {2019-11-21},
    date = {2016-05},
    langid = {english}}

我需要用doi = {...},之间的单词替换@article {......之间的单词。

在此示例中,结果应变为

@article{10.1016/j.cma.2016.01.017,
        title = {Buckling and vibration},
        volume = {303},
        issn = {00457825},
        url = {https://linkinghub.elsevier.com/retrieve/pii/S004578251630010X},
        doi = {10.1016/j.cma.2016.01.017},
        pages = {75--100},
        journaltitle = {Computer Methods in Applied Mechanics and Engineering},
        shortjournal = {Computer Methods in Applied Mechanics and Engineering},
        author = {Mehri, M. and Asadi, H. and Wang, Q.},
        urldate = {2019-11-21},
        date = {2016-05},
        langid = {english}}

1 个答案:

答案 0 :(得分:1)

使用记事本++:

  • Ctrl + H
  • 查找内容:@article{\K.+?(,\R[\s\S]+?doi = {(.+?))(?=},)
  • 替换为:$2$1
  • 检查 匹配案例
  • 检查 环绕
  • 检查 正则表达式
  • 取消检查 . matches newline
  • 全部替换

Demo & Explanation

屏幕截图(之前):

enter image description here

屏幕截图(之后):

enter image description here