Community
    • 登入

    add text before the 2nd last space in each line?

    已排程 已置頂 已鎖定 已移動 General Discussion
    5 貼文 2 Posters 1.1k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • gifthubbroG
      gifthubbro
      最後由 編輯

      I want to add a comma before the 2nd last time in each line of text in notepad ++, heres an example if what I mean : house, Road, westworld, Co. London H509 50565

      so I want to add the comma after London, to make it appear like this: house, Road, westworld, Co. London, H509 50565

      thanks!

      1 條回覆 最後回覆 回覆 引用 0
      • Terry RT
        Terry R
        最後由 編輯

        @gifthubbro said in add text before the 2nd last space in each line?:

        heres an example if what I mean : house, Road, westworld, Co. London H509 50565

        Are you able to confirm that the last piece “H509 50565” exists on all lines. Obviously not those exact characters, but that there are 2 words (a word here is defined as a string of non-blank characters) that need separating by adding the comma on every line. Without that assumption is might be difficult to decide where to place the comma.

        Terry

        gifthubbroG 1 條回覆 最後回覆 回覆 引用 0
        • gifthubbroG
          gifthubbro @Terry R
          最後由 編輯

          @Terry-R thats right all the lines are two words, where I need to insert a comma before these last two words

          1 條回覆 最後回覆 回覆 引用 0
          • Terry RT
            Terry R
            最後由 Terry R 編輯

            @gifthubbro said in add text before the 2nd last space in each line?:

            so I want to add the comma after London

            So that being true, try this.
            Replace function:
            Find What:^(.+)((\h\w+){2})$
            Replace With:\1,\2

            See if that works for you.

            Terry

            gifthubbroG 1 條回覆 最後回覆 回覆 引用 3
            • gifthubbroG
              gifthubbro @Terry R
              最後由 編輯

              @Terry-R thanks that worked!

              1 條回覆 最後回覆 回覆 引用 2
              • 第一個貼文
                最後的貼文
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors