How do i merge lines (Pt. 3)
-
Sorry I should’ve shared this information in the first place so it wasn’nt clear from the start. My sincere apologies, please do have a look at my current information i hope this time it is clear.
@PeterJones @TERRY RWhat I gave in the first place:
3040 Woodsidi 5202 Sivilli Rd 6406 W 81 ST 1853 Yukon Ct
Result came from @PeterJones 's Regex:
3040 Woodsidi 5202 Sivilli Rd 6406 W 81 ST 1853 Yukon Ct
My actual txt:
3040 Woodsidi 56897 246971692 (236) 526 2626 5202 Sivilli Rd 56897 246971692 (236) 526 2626 6406 W 81 ST 56897 246971692 (236) 526 2626 1853 Yukon Ct 56897 246971692 (236) 526 2626
Result came from @PeterJones 's Regex:
3040 Woodsidi 56897 246971692 (236) 526 2626 5202 Sivilli Rd 56897 246971692 (236) 526 2626 6406 W 81 ST 56897 246971692 (236) 526 2626 1853 Yukon Ct 56897 246971692 (236) 526 2626
Result I wanted/expected:
3040 Woodsidi 56897 246971692 (236) 526 2626 5202 Sivilli Rd 56897 246971692 (236) 526 2626 6406 W 81 ST 56897 246971692 (236) 526 2626 1853 Yukon Ct 56897 246971692 (236) 526 2626
Thank you already :)
-
Hi @Faisal-Alam
As long as data provided is representative of the full text — but only you know that —, the following regex meets your needs:
Search: \R(?![\d(]) Replace: \x20
Put the caret at the very beginning of the document, select just the
Regular Expressions mode
and click onReplace All
.Have fun!
-
@astrosofista thanks man! It really worked ❤️ but i still can not use this as my txt actually comprises some other words which i am not posting here because I’m afraid people will call me childish and won’t help anymore. But this way also my work isn’t going to done. If you’re willing to help me through my work then i will post it and if not then no problem. Anyways thank you buddy you really nailed it. Sad for me i can not use this.
-
Hi @Faisal-Alam
I see. You may want to take another approach. Can you elaborate a criterium covering all the relevant details to guide our regex efforts? For example, the criterium I used before was: Replace a LN/CR
\R
by a space\x20
as long as it is not followed?=!
by a number\d
or an open parenthesis(
.Have fun!
-
@Faisal-Alam said in How do i merge lines (Pt. 3):
Sad for me i can not use this
Yep, sad for you.
Also, can you stop opening a new thread each time you want to add something to this overall topic? Just reply within the thread and the site will keep all these common postings together under one heading.
-
@Alan-Kilborn I’m really a newbie here, i use to make my own regex for each barrier i get but I’m unable to do this one so i came here followed by google. Anyways thanks, I’ll keep that in mind next time.
-
@Faisal-Alam said in How do i merge lines (Pt. 3):
my txt actually comprises some other words
I’m surprised that this statement by the OP hasn’t pushed @PeterJones over the edge… :-)
-
hasn’t pushed @PeterJones over the edge
Well, I just found this third topic in the discussion a minute ago, so I hadn’t gotten that far. And since other people had taken over answering, I’ll just ♫Let It Go♫
-
Hello, @faisal-alam, @terry-r, @peterjones, @alan-kilborn, @astrosofista and All,
An other regex solution, which gives an output text identical to @astrosofista’one, would be :
SEARCH
^\d{4}\K\R
REPLACE
\x20
Notes :
-
My search regex
^\d{4}\K\R
approach is to find only the lines whose the line-break must be changed as a space char :-
Searches from beginning (
^
) of line for a number with 4 digits (\d{4}
) -
Then the
\K
syntax cancelled everything that matched so far and, then, it searches for the **line break character(s) (\R
) at the end of that specific line… -
Which is replaced by a space character (
\x20
)
-
-
The @astrosofista’s
search
regex\R(?![\d(])
approach is to find a line break which is not followed with a number or bracket :-
Searches for line-ending characters (
\r
or\n
) but ONLY IF the look-ahead structure(?!......)
is true -
So, IF NOT followed with, either :
-
A digit
\d
-
An opening bracket
(
-
-
Which is replaced by a space character (
\x20
)
-
If these two S/R do not give you the expected text, simply provide us some more substantial data to aim the needed text changes to perform by a regex S/R ;-))
Best Regards,
guy038
-
-
@guy038 Damn brother this worked perfectly tysm