Community
    • Login

    Find/Replace multiple lines

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 364 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dave C 1D
      Dave C 1
      last edited by

      Using Search/Replace I can find “GRID=” in the following text:

      1 EVEN
      2 TYPE FindaGrave
      2 NOTE GRID= somenumber

      I’d like the replacement to read:

      1 EVEN
      2 TYPE R
      2 ADDR somenumber
      2 NOTE GRID=somenumber

      I need to be able store “somenumber” and use that number (it changes) to create the replacement example multiple times in the text file (it’s a GEDcom file). Can this be done in one pass?

      PeterJonesP 1 Reply Last reply Reply Quote 1
      • PeterJonesP
        PeterJones @Dave C 1
        last edited by PeterJones

        @Dave-C-1 said in Find/Replace multiple lines:

        Can this be done in one pass?

        Using regular expression search, yes.

        FIND = 2 NOTE GRID=(\d+)
        REPLACE = 2 ADDR $1\r\n$0

        In the FIND, the (\d+) says "find one or more digits and put in group#1)
        In the REPLACE, the $1 says “use the contents stored in group#1” and the $0 says “use the full matched text”

        ----

        Useful References

        • Please Read Before Posting
        • Template for Search/Replace Questions
        • Formatting Forum Posts
        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors