Hello, @pilltwilliams, @terry-r and All,
As your text, William, seems to have literal headers TEXT_#####_ORIG and TEXT_#####_DEST, which clearly identifies the lines, it’s fairly easy to create the appropriate regex S/R ;-))
So, for instance, assuming that File_A contains the text, even with indented lines, and, possibly, other non-related lines, below :
TEXT_00001_ORIG|This is original text. TEXT_00001_DEST| An other TEXT_00002_ORIG|An original line. TEXT_00002_DEST| little story TEXT_00003_ORIG|More text. TEXT_00003_DEST| TEXT_00004_ORIG|This is TEXT_00004_DEST| just for the TEXT_00005_ORIG|example TEXT_00005_DEST| demonstration TEXT_00006_ORIG|the general TEXT_00006_DEST|and that File_B contains the DEST lines, indented or not, with possible non-related lines, as below :
TEXT_00001_DEST|This is modified text. TEXT_00002_DEST|An altered line. 12345 TEXT_00003_DEST|Even more text. Some bla TEXT_00004_DEST|a small blah text for TEXT_00005_DEST|to get testing TEXT_00006_DEST|idea !Then :
Open a new N++ tab
Paste the File_A contents in this new tab
Insert a line of, at least, 3 tilde characters
Paste the File_B contents, right after
Now, the new tab contains :
TEXT_00001_ORIG|This is original text. TEXT_00001_DEST| An other TEXT_00002_ORIG|An original line. TEXT_00002_DEST| little story TEXT_00003_ORIG|More text. TEXT_00003_DEST| TEXT_00004_ORIG|This is TEXT_00004_DEST| just for the TEXT_00005_ORIG|example TEXT_00005_DEST| demonstration TEXT_00006_ORIG|the general TEXT_00006_DEST| ~~~~~~~~~~ TEXT_00001_DEST|This is modified text. TEXT_00002_DEST|An altered line. 12345 TEXT_00003_DEST|Even more text. Some bla TEXT_00004_DEST|a small blah text for TEXT_00005_DEST|to get testing TEXT_00006_DEST|idea !Open the Replace dialog
SEARCH (?s)^\h*(TEXT_\d+_DEST\|)(?=\R.+\R\h*\1(?-s)(.+)\R)|^(\h*\R)*~~~*.+
REPLACE ?1$0\2
Preferably, check the Wrap around option
Select the Regular expression search mode
Click once, on the Replace All button or several times on the Replace button
Et voilà ;-))
You should get the expected text, below :
TEXT_00001_ORIG|This is original text. TEXT_00001_DEST|This is modified text. An other TEXT_00002_ORIG|An original line. TEXT_00002_DEST|An altered line. little story TEXT_00003_ORIG|More text. TEXT_00003_DEST|Even more text. TEXT_00004_ORIG|This is TEXT_00004_DEST|a small just for the TEXT_00005_ORIG|example TEXT_00005_DEST|to get demonstration TEXT_00006_ORIG|the general TEXT_00006_DEST|idea !Just note that the line of tildes and all the subsequent characters have been wiped out, as well ! The number of replacements is the number of lines TEXT_#####_DEST of File_B + 1
Best Regards
guy038
P.S. :
Be aware that, in some cases ( great amount of data, lot of non-related text between two significant lines, with headers, ... ) this regex S/R could not work properly, and, for instance, wrongly select all file contents :-((