Community
    • Login

    Find/Replace multiple lines

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.0k Views 2 Watching
    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 Offline
      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 Online
        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors