Community
    • Login

    Delete everything after the 5 character in a every line

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 487 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.
    • jacob johnsonJ
      jacob johnson
      last edited by

      Hi
      how to delete everything after the 5 character in a every line

      15230;reherherhkwef…com/; 164; 3
      23018;reherherhkwefk…com/; 164; 3
      26230;reherherhjwejf…com/; 164; 3
      30240;reherherjwejfwh…com/; 164; 3
      29305;reherherhjwekfkw…com/; 164; 3

      final result is

      15230
      23018
      26230
      30240
      29305

      Mark OlsonM 1 Reply Last reply Reply Quote 1
      • Mark OlsonM
        Mark Olson @jacob johnson
        last edited by Mark Olson

        @jacob-johnson
        Thank you for presenting your input and desired output in text format.

        1. Open the find/replace form and select the Replace tab (keyboard shortcut Ctrl+H gets here.
        2. Run the following find-replace:

        Find what: (?-s)^(.{5}).*
        Replace with: ${1}
        Search Mode: Regular expression

        This does the following:

        1. (?-s) makes it so . matches every character except newlines
        2. ^ attempts to match only at the start of a line.
        3. (.{5}) matches the first five characters of the line, and stores them in the first capture group (we’ll come back to this later)
        4. .* matches the rest of the line but does not capture it.

        Then the Replace with ${1} takes the text that was matched and replaces it with the first capture group, meaning that each line is replaced with its first five characters.

        Lines with fewer than five characters will not be affected by this regex-replace, which I assume is what you want.

        Further documentation on regular expressions can be found in this section of the user manual.

        jacob johnsonJ 1 Reply Last reply Reply Quote 2
        • jacob johnsonJ
          jacob johnson @Mark Olson
          last edited by

          @Mark-Olson thank you! :)

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