• Login
Community
  • Login

How to find a line by a tag and remove data from line.

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 2 Posters 241 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.
  • A
    Ashley Hoogenboom
    last edited by Feb 15, 2022, 3:56 AM

    I am trying to find all lines that start with T: and remove the report code and date, leaving only the description.

    Sample of what file looks like to start:

    T:BKMJALL DAILY MAINTENANCE JOURNAL ALL USERS/APPS 2018/01/02
    Y:1
    C0:BKMJALL
    D:1/5/2018 8:51:56 AM
    T:GL5324P UNPOSTED ITEM LISTING - DETAIL 2018/01/02
    Y:1
    C0:GL5324P

    Expected outcome:

    T:DAILY MAINTENANCE JOURNAL ALL USERS/APPS
    Y:1
    C0:BKMJALL
    D:1/5/2018 8:51:56 AM
    T:UNPOSTED ITEM LISTING - DETAIL
    Y:1
    C0:GL5324P

    Is there a way to do this with notepad++?

    Thank you!

    N 1 Reply Last reply Feb 15, 2022, 8:18 AM Reply Quote 0
    • N
      Neil Schipper @Ashley Hoogenboom
      last edited by Feb 15, 2022, 8:18 AM

      @ashley-hoogenboom Hello.

      If your data is as well behaved (uniform) as the samples suggest, this should meet your need:

      Ctl-h (replace dialog)
      Search Mode=RegExp ; box to the right not checked
      F: (?<=T:)(\w+\h)(.+)(\h\d{4}/\d{2}/\d{2}$)
      R: \2
      Replace all

      There are actually quite a few subtly different interpretations possible (based on characteristics of the text to remove, and, amounts of whitespace) so carefully check lots of records for false positives (too much removed) or false negatives (too little).

      A 1 Reply Last reply Feb 15, 2022, 5:34 PM Reply Quote 3
      • A
        Ashley Hoogenboom @Neil Schipper
        last edited by Feb 15, 2022, 5:34 PM

        @neil-schipper Thank you so much, that worked perfectly! I have a huge project ahead of myself and this really helped! Thank you!

        N 1 Reply Last reply Feb 15, 2022, 5:53 PM Reply Quote 0
        • N
          Neil Schipper @Ashley Hoogenboom
          last edited by Feb 15, 2022, 5:53 PM

          @ashley-hoogenboom Appreciation appreciated.

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