• Login
Community
  • Login

append text to some lines only

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 3 Posters 377 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.
  • N
    namx3249
    last edited by May 10, 2023, 7:05 AM

    hi great community,

    i need to append text to some lines only. this is an example of my document:

    #EXT2836,
    https://blabla
    #EXT392,
    https://blgahsa
    #EXT9161,
    https://agglo
    

    i need to append text to https line only, like this one:

    #EXT2836,
    https://blabla66666
    #EXT392,
    https://blgahsa66666
    #EXT9161,
    https://agglo66666
    

    i know how to append text to all lines with:
    find: $
    replace: 66666

    but this regex append text to all lines. i need to append text only to https lines

    so, i need help on replace field:
    find: (?-s)https://.*
    replace: 66666 (need help here)

    1 Reply Last reply Reply Quote 1
    • L
      litos81
      last edited by litos81 May 10, 2023, 7:21 AM May 10, 2023, 7:21 AM

      Hi @namx3249,

      a simple way I can think of:
      Find: ^https.*\K
      Replace with: 66666

      \K resets the starting point of the reported match, then you can just type the appended text in the Replace field.

      The setting . matches newline in the Replace dialog is unchecked.

      1 Reply Last reply Reply Quote 3
      • N
        namx3249
        last edited by May 10, 2023, 7:48 AM

        oh yes, work fine. thank you

        this option \K it’s really new for me. thanks again for your tip

        A 1 Reply Last reply May 10, 2023, 1:57 PM Reply Quote 0
        • A
          Alan Kilborn @namx3249
          last edited by May 10, 2023, 1:57 PM

          @namx3249

          Note that \K is only going to work if you’re doing a Replace All.
          It won’t work with a step-by-step Replace.

          1 Reply Last reply Reply Quote 3
          • N
            namx3249
            last edited by May 10, 2023, 3:05 PM

            yes Alan, i’ve see that !

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