sayros
sayros

Reputation: 115

How to find a text between two characters and replace it by a text between another two characters in notepad++?

I have many file with the following structure

    @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}}

I need to replace the words between @article{......, by the word between doi = {...}, .

For this example results should become

@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}}

Upvotes: 0

Views: 33

Answers (1)

Toto
Toto

Reputation: 91518

Using notepad++:

  • Ctrl+H
  • Find what: @article{\K.+?(,\R[\s\S]+?doi = {(.+?))(?=},)
  • Replace with: $2$1
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Demo & Explanation

Screen capture (before):

enter image description here

Screen capture (after):

enter image description here

Upvotes: 1

Related Questions