How do I merge two or more consecutive lines into one?
-
Hi, glossar and Vasile,
Hum… Very strange ! As for me, it works quite fine ! So, Vasile, let’s recapitulate :
-
glossar, from your original text, below :
Line 344: bördelversuch TAB flanging test
Line 345: bördelversuch TAB folding test
…
Line 28872: führungszapfen TAB guide pilot
Line 28873: führungszapfen TAB guide pin
Line 28874: führungszapfen TAB pilot pin
…
Line 659368: horizontal geteilt TAB horizontally divided
Line 659369: horizontal geteilt TAB horizontally split -
And, taking in account that :
-
The string
TAB
, with a space character before and after, refers to a single tabulation character\t
, of code\x09
-
The part
line number #####:
, that begins each line, for information, must be deleted
-
We, finally, get the text, to work on :
bördelversuch flanging test bördelversuch folding test führungszapfen guide pilot führungszapfen guide pin führungszapfen pilot pin horizontal geteilt horizontally divided horizontal geteilt horizontally split
Now,
-
Move back the caret before the first line
-
Open the Replace dialog ( Ctrl + H )
-
In the Find what zone, type the regex
(?-s)^((.+\t).+)\R\2(.+)
-
In the Replace with zone, type the regex
\1, \3
, with a SPACE character, after the comma symbol -
Select the Regular expression search mode
-
Uncheck all the other options
-
Click THREE times, on the Replace All button, till the message Replace All: 0 occurrences were replaced is displayed, in blue, at the bottom of the Replace dialog
You should get,as expected, the replaced text, below :
bördelversuch flanging test, folding test führungszapfen guide pilot, guide pin, pilot pin horizontal geteilt horizontally divided, horizontally split
Cheers,
guy038
-
-
hello Guy, nope, is not working. Please take a look on this print screen:
or here
-
Guy - You’re the man! :) Thanks a million! It works! I can’t believe it, but it works!
Thank you!
By the way, I like the way you write, your writing style, and enjoy reading your posts! :)
-
No, Vasile, it works!
Here is my screenshot! :)
By the way, this “Snaggy” website is cool! Posting a screenshot couldn’t indeed be easier! I have bookmarked it! Thank you! :)
And finally, I find it a silly practice that new users have to wait for 1200 seconds in order for them to submit their second post!
-
Hello, Vasile,
Ah, yes ! Quite weird ! From your print screen pictures, everything seems OK : We, both, have the same fields and options and, from the status bar, our encoding and line breaks are also identical !!??
Moreover, I verified that the Glossar’s text, inserted in your new tab, does have the same displaying than my text ! This implies that you correctly inserted the tabulation characters ( of 4 spaces characters, by default, like me ) !!??
So, the only thing that could explain the search failure should be, that you, probably, inserted some invisible character(s) in the search regex ?
But, I must admit that I’m really annoyed to not being able to point out the true reason of your N++'s search behaviour !
See you later…
Cheers,
guy038
P.S. :
Glossar, just see your reply to Vasile. Quite pleased that it works as expected, on your configuration !
BTW, some of us may could test my regex ? May be, it will help us to identify the problem :-)
One more point, Vasile, which N++ version are you using ?
-
hello. I am using v7.1, no update available.
But, I had an error yesterday morning, something when N++ had to update Plugin Manager and a Npp plugin, don’t remember very well. I will restart the computer tomorow, and I will test again.
-
no, after restart nothing change. And I installed the v.722, ant still doesn’t work. What a bug is this?
-
@guy038 said:
Click THREE times, on the Replace All button, till the message Replace All: 0 occurrences were replaced is displayed, in blue, at the bottom of the Replace dialog
Out of curiosity I tried it, and found that I had to press Replace All only TWO times to get a complete replacement on these three groupings of text. The first press of Replace All does the first and third sets of data; the second press does the second set. However, in the end, it changed the data as expected.
-
Hi, Scott, glossar and vasile,
Yes, Scott, two times are enough, indeed !. However, I replied to glossar for the general case where you do not know, exactly, what is the maximum of lines with “identical beginnings”, because of a huge file, for instance !
In that case, it’s better to click on the Replace All button till the message 0 occurrences were replaced appears ! Indeed, as long as yon obtain the message
N
occcurrences were replaced, withN > 0
, you cannot guess that no more occurrence has to be replaced, the next time :-))Cheers,
guy038
-
I press 50 times “Replace all”, and nothing happen. There is a bug somewhere…
-
this is working fine !
-
hello guy38, and all friends. Maybe you can improve my regex to resolve the solution (other way).
So, the regex below will bind (merge) all the sentences into one. The problem is that is not cut the words that repeats.
Search:
\s+(.*?)Replace with:
leave space
-
there will be another good solution, that works:
Find What:
^(\w+\s+\w+\s*)(.*)\n\1
Replace With:\1\2,
-
@guy038 How can I combine a specific line with a character, ei. Line 2 - 7 should be in line 2 only. and same with the others