Hello, @Matthew-suhajda, and All,
Pleased to hear that it worked fine ! Just for information :
Regarding the first S/R :
SEARCH (?-s)^(?:.*\R){2}(.+)(?s).+
REPLACE $0\r\n\1
The modifier (?-s) means that, further dots will match any single character, only
Then, the part ^(?:.*\R){2} looks for the first two lines, with their EOL chars, in a non capturing group
Now, the part (.+) stores, as group 1, the next 3rd line, without its End of Line characters
Finally, the (?s).+ syntax catches all remaining text from End of Line characters of line 3
In replacement, due to the $0 syntax, it re-writes, first, the entire matched text ( = file contents ), followed with a Windows line break ( \r\n ) and, finally, with the group 1 ( = The 3rd line = time stamp )
Regarding the second S/R :
SEARCH (?i)foo(?s)(?=.*\R(.+)\z)|(?-s)\R.+\z
REPLACE ?1foo\x20\1
The searched regex is made of two alternatives, separated by the alternation special character | :
(?i)foo(?s)(?=.*\R(.+)\z)
(?-s)\R.+\z
In the first alternative, the part (?i)foo tries, first, to match the foo word, in any case
Then, the (?s)(?=.*\R(.+)\z) syntax represents an always true look-ahead, (?=......), which matches all text after the foo word, till the second to the last line ( .*\R ), and the last ( or 3rd ) line, without any line-break ( (.+)\z ), which is stored as group 1
Near the end of each file, the second alternative, (?-s)\R.+\z, looks for the very last ( or 3rd ) line contents, till the very end of each file ( \z )
In replacement, the ?1foo\x20\1 syntax means :
If group 1 exists, it rewrites the entire matched string foo, followed with a space character and the time stamp ( last ) line ( \1 )
If group 1 does not exist ( case of the second alternative ), the very last line, temporarily added, is then, simply, deleted, as no ELSE part is present in the conditional replacement ?1..... !
Best Regards,
guy038