Community
    • Login

    help to delete some blank lines

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 227 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.
    • namx3249N
      namx3249
      last edited by

      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
      • guy038G
        guy038
        last edited by guy038

        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
        • namx3249N
          namx3249
          last edited by

          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
          • guy038G
            guy038
            last edited by guy038

            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
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors