Community
    • 登入

    Newbie question - search and replace with wildcard

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    6 貼文 2 Posters 390 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Fredrik KonradssonF
      Fredrik Konradsson
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 0
      • Alan KilbornA
        Alan Kilborn @Fredrik Konradsson
        最後由 編輯

        @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 條回覆 最後回覆 回覆 引用 2
        • Alan KilbornA
          Alan Kilborn @Fredrik Konradsson
          最後由 編輯

          @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 條回覆 最後回覆 回覆 引用 1
          • Fredrik KonradssonF
            Fredrik Konradsson @Alan Kilborn
            最後由 編輯

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

            Alan KilbornA 1 條回覆 最後回覆 回覆 引用 3
            • Alan KilbornA
              Alan Kilborn @Fredrik Konradsson
              最後由 編輯

              @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 條回覆 最後回覆 回覆 引用 1
              • Fredrik KonradssonF
                Fredrik Konradsson @Alan Kilborn
                最後由 編輯

                @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 條回覆 最後回覆 回覆 引用 1
                • 第一個貼文
                  最後的貼文
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors