Community
    • Login

    separate to a NEW file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 4 Posters 172 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.
    • Mostafa KamalM
      Mostafa Kamal
      last edited by

      how can i separate last 3 words from 200k rows list to a new file ?
      i mean 470124, here i want to last 3 digits to a new file,

      dr ramaanandD Terry RT PeterJonesP 3 Replies Last reply Reply Quote 0
      • dr ramaanandD
        dr ramaanand @Mostafa Kamal
        last edited by

        @Mostafa-Kamal Please give us the input text or string and the desired output

        1 Reply Last reply Reply Quote 0
        • Terry RT
          Terry R @Mostafa Kamal
          last edited by Terry R

          @Mostafa-Kamal said in separate to a NEW file:

          i mean 470124, here i want to last 3 digits to a new file,

          You use “words” but your example suggests 3 characters. If so then first make a copy of the file as the copied file will contain the 3 characters per line.
          Find What:(?-s)^.*(...)$
          Replace With:\1

          The search mode must be “regular expression”, click on “Replace All” to change the file content.

          Each DOT (.) character refers to a single character position in the file. The last 3 characters are saved into a group (1) which is written back. The extra characters on each line are effectively removed.

          Terry

          1 Reply Last reply Reply Quote 2
          • PeterJonesP
            PeterJones @Mostafa Kamal
            last edited by

            @Mostafa-Kamal ,

            if it’s a one-time action, @Terry-R’s suggestion is spot on, and you don’t need to read my post.

            However, if it’s an action you are going to take a lot, I would suggest recording a macro:

            1. Macro > Start Recording
            2. Search > Mark
              • FIND WHAT: \d{3}$ (this assumes it’s always a digit, like in your example; if it is just the last three characters, whether it’s digit or not, then .{3}$ instead
              • Uncheckmark Bookmark line
              • Checkmark Purge for each search
              • Mark All
              • Copy Marked Text
              • Clear all marks
              • Close
            3. File > New
            4. Edit > Paste
            5. Macro > Stop Recording
            6. Macro > Save Current Recorded Macro
              • Give it a name that makes sense to you (CopyLastDigitsToNewFile or something)
              • Give it a keyboard shortcut if desired.

            From now on, you can run the macro to copy those last digits/characters to a new file.

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