@swen-reindl, @terry-r, @perterjones and All,
The drawback of my first method is that you needed very similar structure of the two files, in order to keep a constant gap between the line to replace and the line which must replace it :-(
So, here is my second attempt, which needs two regex S/R but which can be used in all cases, whatever the file’s structure ! Indeed, it simply :
Searches for the first line, beginning with the vertex string, after a line outer loop, in File 1
Replace that line with the first line, beginning with the vertex string, after a line outer loop, in File 2
Copy the File 1 contents in a new N++ tab
Add a simple line of, at least, 3 tildes, right after the contents
Now, append the File 2 contents, right after the line of tildes
So, let’s suppose that we get this sample text, where I added some bla bla bla lines, at random locations
# File 1 facet normal 0 0 -1 bla bla bla bla blah outer loop bla bla bla bla blah vertex 0 -4.7850790023803711 3.5992410182952881 bla bla bla bla blah bla bla bla bla blah vertex -8.2880001068115234 -9.5701580047607422 3.5992410182952881 vertex -8.2880001068115234 9.5701580047607422 3.5992410182952881 endloop bla bla bla bla blah endfacet facet normal 0 0 -1 outer loop bla bla bla bla blah bla bla bla bla blah bla bla bla bla blah vertex 0 4.7850785255432129 3.5992410182952881 vertex 8.2880001068115234 -2.384185791015625e-07 3.5992410182952881 bla bla bla bla blah bla bla bla bla blah vertex 0 -4.7850790023803711 3.5992410182952881 endloop endfacet bla bla bla bla blah bla bla bla bla blah facet normal 0 0 -1 outer loop vertex -8.2880001068115234 9.5701580047607422 3.5992410182952881 bla bla bla bla blah bla bla bla bla blah vertex 0 4.7850785255432129 3.5992410182952881 vertex 0 -4.7850790023803711 3.5992410182952881 endloop bla bla bla bla blah endfacet ~~~~~~~~~~ # File 2 facet normal -0 -0 -1 outer loop bla bla bla bla blah bla bla bla bla blah vertex 0 4.7850790023803711 0 bla bla bla bla blah vertex 8.2880001068115234 9.5701580047607422 0 vertex 8.2880001068115234 -9.5701580047607422 0 endloop endfacet facet normal -0 -0 -1 outer loop vertex 0 -4.7850785255432129 0 bla bla bla bla blah bla bla bla bla blah bla bla bla bla blah vertex -8.2880001068115234 2.384185791015625e-07 0 vertex 0 4.7850790023803711 0 endloop endfacet facet normal -0 -0 -1 bla bla bla bla blah bla bla bla bla blah bla bla bla bla blah outer loop bla bla bla bla blah vertex 8.2880001068115234 -9.5701580047607422 0 vertex 0 -4.7850785255432129 0 vertex 0 4.7850790023803711 0 endloop bla bla bla bla blah bla bla bla bla blah endfacetNow , open the Replace dialog ( Ctrl + H )
Type in the regex (?s).+?(?|(\R~~~+)|outer loop.*?(?-s)(\Rvertex .+))|(?s).+ , in the Find what: zone
Type in the regex \1 , in the Replace with: zone
Check the Wrap around option
Select the Regular expression search mode
Click, once, on the Replace All button
You should obtain this shorter text, with only the lines which need to be replaced and their counterparts which must replace them ;-))
vertex 0 -4.7850790023803711 3.5992410182952881 vertex 0 4.7850785255432129 3.5992410182952881 vertex -8.2880001068115234 9.5701580047607422 3.5992410182952881 ~~~~~~~~~~ vertex 0 4.7850790023803711 0 vertex 0 -4.7850785255432129 0 vertex 8.2880001068115234 -9.5701580047607422 0Then , it’s fairly obvious :
Insert the File 1 contents at the very beginning of that new tab
Add, again, a simple line of, at least, 3 tildes, right after the contents
Hence, the new tab contents becomes :
# File 1 facet normal 0 0 -1 bla bla bla bla blah outer loop bla bla bla bla blah vertex 0 -4.7850790023803711 3.5992410182952881 bla bla bla bla blah bla bla bla bla blah vertex -8.2880001068115234 -9.5701580047607422 3.5992410182952881 vertex -8.2880001068115234 9.5701580047607422 3.5992410182952881 endloop bla bla bla bla blah endfacet facet normal 0 0 -1 outer loop bla bla bla bla blah bla bla bla bla blah bla bla bla bla blah vertex 0 4.7850785255432129 3.5992410182952881 vertex 8.2880001068115234 -2.384185791015625e-07 3.5992410182952881 bla bla bla bla blah bla bla bla bla blah vertex 0 -4.7850790023803711 3.5992410182952881 endloop endfacet bla bla bla bla blah bla bla bla bla blah facet normal 0 0 -1 outer loop vertex -8.2880001068115234 9.5701580047607422 3.5992410182952881 bla bla bla bla blah bla bla bla bla blah vertex 0 4.7850785255432129 3.5992410182952881 vertex 0 -4.7850790023803711 3.5992410182952881 endloop bla bla bla bla blah endfacet ~~~~~~~~~~ vertex 0 -4.7850790023803711 3.5992410182952881 vertex 0 4.7850785255432129 3.5992410182952881 vertex -8.2880001068115234 9.5701580047607422 3.5992410182952881 ~~~~~~~~~~ vertex 0 4.7850790023803711 0 vertex 0 -4.7850785255432129 0 vertex 8.2880001068115234 -9.5701580047607422 0Open, again, the Replace dialog ( Ctrl + H )
Type in the regex ^outer loop(?s).*?\K(?-s)(^vertex.+)(?=(?s:\R.+?\R~~~.+?)\1\R(?:.+\R){3}(.+))|(?s)^~~~.+ , in the Find what: zone
Type in the regex \2 , in the Replace with: zone
Check the Wrap around option
Select the Regular expression search mode
Click, once, on the Replace All button ( Do NOT use the Replace button, because of the \K feature in the search regex )
Here we are ! We get, in our new tab, just the new File 1 contents, after all the replacements ;-))
# File 1 facet normal 0 0 -1 bla bla bla bla blah outer loop bla bla bla bla blah vertex 0 4.7850790023803711 0 bla bla bla bla blah bla bla bla bla blah vertex -8.2880001068115234 -9.5701580047607422 3.5992410182952881 vertex -8.2880001068115234 9.5701580047607422 3.5992410182952881 endloop bla bla bla bla blah endfacet facet normal 0 0 -1 outer loop bla bla bla bla blah bla bla bla bla blah bla bla bla bla blah vertex 0 -4.7850785255432129 0 vertex 8.2880001068115234 -2.384185791015625e-07 3.5992410182952881 bla bla bla bla blah bla bla bla bla blah vertex 0 -4.7850790023803711 3.5992410182952881 endloop endfacet bla bla bla bla blah bla bla bla bla blah facet normal 0 0 -1 outer loop vertex 8.2880001068115234 -9.5701580047607422 0 bla bla bla bla blah bla bla bla bla blah vertex 0 4.7850785255432129 3.5992410182952881 vertex 0 -4.7850790023803711 3.5992410182952881 endloop bla bla bla bla blah endfacetNote that the {3} quantifier, in the search regex, is, exactly, the number of vertex......... lines which must be modified. So, the number 3 in that present example
Cheers,
guy038