Memole1990 last edited by
This post is deleted!
PeterJones last edited by PeterJones
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 05914then 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 05914line, or whether it always starts with
200 05978no matter where in the file after the date line, or whether it’s always exactly
200 05978 0000and 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 yyyymmddline, 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.