Community
    • Login

    I want to delete everything accept my ip and port on each line.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 1.9k Views 1 Watching
    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.
    • upperkingU Offline
      upperking
      last edited by

      Delete multiple lines
      I want to delete everything accept these numbers 76.247.131.161:57524<— this number changes and I want to keep on each line
      I cant figure out how to do it correctly…

      21 76.247.131.161:57524, Port:5524, 27012, RCON:27300, DIR:21, PID:45696, Name:
      22 76.247.131.161:57544, Port:5544, 27022, RCON:27305, DIR:22, PID:23584, Name:
      23 76.247.131.161:57564, Port:5564, 27032, RCON:27310, DIR:23, PID:26192, Name:
      24 76.247.131.161:57584, Port:5584, 27042, RCON:27315, DIR:24, PID:51116, Name:

      so it looks like this

      76.247.131.161:57524
      76.247.131.161:57544
      76.247.131.161:57564
      76.247.131.161:57584

      1 Reply Last reply Reply Quote 1
      • guy038G Offline
        guy038
        last edited by guy038

        Hello @upperking, and All,

        @upperking, welcome to the Notepad++ Community !

        Elementary, with a simple regex S/R :

        • Open the Replace dialog ( Ctrl + H )

        • Type in (?-is),\x20?Port.+ in the Find what : zone

        • Leave the Replace with: zone EMPTY

        • If necessary, tick the Wrap around option

        • Select the Regular expression search mode ( IMPORTANT )

        • Click once on the Replace All button or several times on the Replace button

        Et voilà !

        Notes :

        • The in-line modifiers (?-is) forces the search to be performed in a non-insensitive way and the dot . to match a single standard character only

        • Then, the part ,\x20?Port looks for a comma, followed with an optional space char and the string Port, in that exact case

        • Finally, the part .+ search for any non-null range of standard characters

        • As the Replacement zone is empty, the range , Port.........., ending any line is deleted

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 2
        • upperkingU Offline
          upperking
          last edited by

          holy crap that was amazing thank you…

          One last issue how do I delete numbers on each line like example.
          https://gyazo.com/1bc37153673f725c00bbae338937aa37

          1 Reply Last reply Reply Quote 0
          • guy038G Offline
            guy038
            last edited by guy038

            Hi @upperking,

            Oupppss ! I should have read your post more carefully ! We must take the leading numbers in account ;-))

            So, change the Find and Replace zones, as below :

            SEARCH (?-is)^\d+\x20(76\.247\.131\.161:\d+).+

            REPLACE \1

            Notes :

            • Beware : if the IP address is not exactly the address 76.247.131.161, nothing is then replaced

            • The part ^\d+\x20 represents any number, beginning a line and followed with a space character

            • The dot meta character . is escaped with the \ to be considered as a literal

            • The group 1 is the string 76.247.131.161 followed with a colon, followed with the port number, which is rewritten, during the replacement phase

            Cheers,

            guy038

            1 Reply Last reply Reply Quote 3

            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