Community
    • Login

    Newbie question - search and replace with wildcard

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 2 Posters 304 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.
    • Fredrik KonradssonF
      Fredrik Konradsson
      last edited by

      Hi,
      I’ve tried to find the solution for this question but I got stuck. Hopefully someone can help me out. I have a text file where I would like to make a search and replace

      String to search for: “1” .* “1” where the .* can be anything but between two tabs and “1” . I find the strings with this to search for but feel free to correct me.

      I would like to keep the data in the middle just change the second “1” to “6”

      So: “1” “100” “1” would become “1” “100” “6”
      And: “1” “99994” “1” would become “1” “99994” “6”

      Can someone please help me out ?!

      Many thanks
      Fredrik from Sweden.

      Alan KilbornA 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Fredrik Konradsson
        last edited by

        @Fredrik-Konradsson

        Try Regular expression search mode.

        find: (?-s)"1".*?"\K1(?=")
        repl: 6

        I realize there is a lot going on in that find expression, for a newbie.

        Reference the regular-expression information in our FAQ section.

        1 Reply Last reply Reply Quote 2
        • Alan KilbornA
          Alan Kilborn @Fredrik Konradsson
          last edited by

          @Fredrik-Konradsson said in Newbie question - search and replace with wildcard:

          String to search for: “1” .* “1” where the .* can be anything

          I should have stated that your first try at it was not bad, not bad, indeed! :-)

          Fredrik KonradssonF 1 Reply Last reply Reply Quote 1
          • Fredrik KonradssonF
            Fredrik Konradsson @Alan Kilborn
            last edited by

            @Alan-Kilborn Ohh, many thanks. Saved my day! That I wouldn’t have figured out my self : ) Have a nice weekend.

            Alan KilbornA 1 Reply Last reply Reply Quote 3
            • Alan KilbornA
              Alan Kilborn @Fredrik Konradsson
              last edited by

              @Fredrik-Konradsson

              Of course, for this one TMTOWTDI.

              Here’s another, which might be more along the track you were originally going:

              find: (?-s)("1".*?)"1"
              repl: ${1}"6"

              That one might be clearer.

              But anyway, good that it is solved for you.

              Fredrik KonradssonF 1 Reply Last reply Reply Quote 1
              • Fredrik KonradssonF
                Fredrik Konradsson @Alan Kilborn
                last edited by

                @Alan-Kilborn said in Newbie question - search and replace with wildcard:

                find: (?-s)(“1”.*?)“1”
                repl: ${1}“6”

                Many thanks! I really appriciate your help.

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors