help to delete some blank lines
-
hello to everybody,
i have some documents with up to 10K lines like this one:
text-001 text-002 https://www.486905968046wdGtqQT09/74662-7z https://www.ajjdhflfkgwdGteds/74662-7z https://www.erlkjglegio45gio8/74662-7z text-003 text-004 https://www.lSHM3UmJ2MW1rcEh3QT13/1982827-7z text-005 text-006 https://www.tVbkQxTmd2a0lYMVc28193/1quehhs-rar https://www.kfjdhdh7742222/1quehhs-rar https://www.949iwjdjnnssbabqq/1quehhs-rari need to delete blank empty lines only on https lines, like this:
text-001 text-002 https://www.486905968046wdGtqQT09/74662-7z https://www.ajjdhflfkgwdGteds/74662-7z https://www.erlkjglegio45gio8/74662-7z text-003 text-004 https://www.lSHM3UmJ2MW1rcEh3QT13/1982827-7z text-005 text-006 https://www.tVbkQxTmd2a0lYMVc28193/1quehhs-rar https://www.kfjdhdh7742222/1quehhs-rar https://www.949iwjdjnnssbabqq/1quehhs-rarhow to?
or another solution: delete all blank lines, but then add new blank lines only between https link and text-00n -
Hello, @namx3249 and All,
As usual, not difficult with the appropriate regex expression
So, starting with your INPUT text, where I added a leading TAB char before the first part of your text :
text-001 text-002 https://www.486905968046wdGtqQT09/74662-7z https://www.ajjdhflfkgwdGteds/74662-7z https://www.erlkjglegio45gio8/74662-7z text-003 text-004 https://www.lSHM3UmJ2MW1rcEh3QT13/1982827-7z text-005 text-006 https://www.tVbkQxTmd2a0lYMVc28193/1quehhs-rar https://www.kfjdhdh7742222/1quehhs-rar https://www.949iwjdjnnssbabqq/1quehhs-rarthe following regex S/R :
SEARCH
(?-s)^(.+\R)\R+(?=[\t\x20]*http)REPLACE
\1Will produce your expected OUTPUT text :
text-001 text-002 https://www.486905968046wdGtqQT09/74662-7z https://www.ajjdhflfkgwdGteds/74662-7z https://www.erlkjglegio45gio8/74662-7z text-003 text-004 https://www.lSHM3UmJ2MW1rcEh3QT13/1982827-7z text-005 text-006 https://www.tVbkQxTmd2a0lYMVc28193/1quehhs-rar https://www.kfjdhdh7742222/1quehhs-rar https://www.949iwjdjnnssbabqq/1quehhs-rarBest Regards,
guy038
-
oh guy038, as usual your regex work fine!
thanks you so much. you saved my dayonly don’t understand why have you add a leading TAB on first block … it work fine also without this …
-
Hi, @namx3249 and All,
Ah…, I simply added a leading
TABchar before each line of the first part to show you that the regex S/R could also handle this case !But, If you’re sure that leading blank chars won’t appear in your file, you can simplify the regex S/R as below, to get a similar OUTPUT :
SEARCH
(?-s)^(.+\R)\R+(?=http)REPLACE
\1BR
guy038
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login