Community
    • Login

    Change values

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 298 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.
    • Memole1990M
      Memole1990
      last edited by

      This post is deleted!
      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Memole1990
        last edited by PeterJones

        @memole1990 ,

        First off, Notepad++ has two plus characters at the end of the name; that differentiates it from the “Microsoft Notepad” app that ships with your OS.

        The algorithm you described (which I would phrase “look for a line which starts with 200 05914 then has a third ‘word’ on the line of an 8 digit number representing the date in yyyymmdd format, then compare that date to March 31, 2022, then delete that line and one other line if the date is after March 31, or keep it if it’s on-or-before that threshold”. (*: For that “one other line”, you give the example of 200 05978, but you don’t tell us exactly the rule for that second line, whether it’s always 3 lines below the 200 05914 line, or whether it always starts with 200 05978 no matter where in the file after the date line, or whether it’s always exactly 200 05978 0000 and nothing else would match and thus be deleted).

        That algorithm includes a numeric comparison (whether it literally compares the yyyymmdd 8digit numbers, or whether it compares the underlying date in some other manner)… but unfortunately for your desire, the Notepad++ search/replace syntax (including the ultra-powerful regular expression syntax) doesn’t do numerical or date comparisons, it is just looking for patterns of strings.

        Thus, your task cannot be reasonable accomplished natively in Notepad++. (I say “reasonably”, because with a complicated enough comparison pattern, you could effectively implement a single numerical comparison in a huge regular expression, but it might not fit within Notepad++ ~2000 character regular expression limit.)

        If I were solving this task for myself, I would just write a program to do it in my favorite interpreted programming language. If I were solving this problem for someone who didn’t know any programming languages, but they were willing to install a plugin for Notepad++, I would have them install the PythonScript plugin, and I would give them a short script that would do pattern matching to find the 200 05914 yyyymmdd line, then do the numeric comparison in the python, then if it passes the deletion rule, delete the two lines. But before coding something up for someone else, I would insist upon a clear definition that got rid of the ambiguities I mentioned earlier.

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