Community
    • Login

    Newbie question - search and replace with wildcard

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 2 Posters 668 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 Offline
      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 Offline
        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 Offline
          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 Offline
            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 Offline
              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 Offline
                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

                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