• Login
Community
  • Login

help to delete some blank lines

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 2 Posters 229 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N
    namx3249
    last edited by Jun 4, 2023, 8:19 AM

    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-rar
    

    i 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-rar
    

    how to?
    or another solution: delete all blank lines, but then add new blank lines only between https link and text-00n

    1 Reply Last reply Reply Quote 0
    • G
      guy038
      last edited by guy038 Jun 4, 2023, 12:57 PM Jun 4, 2023, 12:39 PM

      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-rar
      

      the following regex S/R :

      SEARCH (?-s)^(.+\R)\R+(?=[\t\x20]*http)

      REPLACE \1

      Will 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-rar
      

      Best Regards,

      guy038

      1 Reply Last reply Reply Quote 2
      • N
        namx3249
        last edited by Jun 4, 2023, 1:26 PM

        oh guy038, as usual your regex work fine!
        thanks you so much. you saved my day

        only don’t understand why have you add a leading TAB on first block … it work fine also without this …

        1 Reply Last reply Reply Quote 1
        • G
          guy038
          last edited by guy038 Jun 4, 2023, 3:15 PM Jun 4, 2023, 3:11 PM

          Hi, @namx3249 and All,

          Ah…, I simply added a leading TAB char 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 \1

          BR

          guy038

          1 Reply Last reply Reply Quote 2
          4 out of 4
          • First post
            4/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors