Community
    • Login

    I need a function/plugin to extract only unnecessary text from lines

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 15 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.
    • Ragnar LodbrokR
      Ragnar Lodbrok
      last edited by PeterJones

      I need a function/plugin to extract only unnecessary text from lines

      Notepad++ v8.7.1 (64-bit)
      Build time : Oct 31 2024 - 00:48:56
      Path : C:\Program Files\Notepad++\notepad++.exe
      Command Line : “C:\Users\RagnarLodbrok\Desktop\chomik hity.txt”
      Admin mode : ON
      Local Conf mode : OFF
      Cloud Config : OFF
      Periodic Backup : ON
      OS Name : Windows 10 Enterprise LTSC 2021 (64-bit)
      OS Version : 21H2
      OS Build : 19044.5608
      Current ANSI codepage : 1250
      Plugins :
      mimeTools (3.1)
      NppConverter (4.6)
      NppExport (0.4)

      chciałbym aby taką operację mógł wykonać, mam taki plik wiersze w pliku 
      karolsieczko1:Kaaarolek24 | Dostępny transfer = 50 MB | Punkty = 1000
      darek221:Darek221 | Dostępny transfer = 270,8 MB | Punkty = 1000
      tomzdw:sztepci0 | Dostępny transfer = 127,41 MB | Punkty = 1000
      rpiecuch:ra3f0p6 | Dostępny transfer = 50 MB | Punkty = 1000
      morgrim9:norekk123 | Dostępny transfer = 50 MB | Punkty = 1000
      

      and I would like to receive such a file with the words removed
      this is what it would look like:

      karolsieczko1:Kaaarolek24
      darek221:Darek221
      tomzdw:sztepci0
      rpiecuch:ra3f0p6
      

      Manually deleting such texts takes days, so my question is: is there a plugin, command, or other solution? Sorry for the inquiries, but I’m completely unfamiliar with such processes. Best regards.

      —

      moderator added code markdown around text; please don’t forget to use the </> button to mark example text as “code” so that characters don’t get changed by the forum

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Ragnar Lodbrok
        last edited by

        @Ragnar-Lodbrok ,

        My suggestion: Use the Search > Replace menu action (or Ctrl+H as the default shortcut):

        • FIND WHAT = ^(\w+:\w+)?.*$(\R)?
        • REPLACE WITH = ?1$1$2
        • SEARCH MODE = Regular Expression

        then use REPLACE ALL button

        The FIND WHAT puts any xyz123:abc987 at the beginning of a line into memory group #1, skips over the rest of the line, and puts the newline sequence in group#2.
        The REPLACE with will replace that entire line with just the contents of group#1 followed by group#2 (so the xyz123:abc987 and newline) IF the xyz123:abc987 exists; if it DOESN’T exist, it will replace the entire line with nothing (hence deleting the line)

        I believe this does what you want.

        ----

        Useful References

        • Please Read Before Posting
        • Template for Search/Replace Questions
        • Formatting Forum Posts
        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors