Loading ...
Sorry, an error occurred while loading the content.
 

Blank lines, and how to get rid of them?

Expand Messages
  • Marcelo de Castro Bastos
    I ran into an odd problem. I was creating a clip to automate some reformatting I do in a file I receive regularly. One of the steps is to get rid of all the
    Message 1 of 4 , Nov 12, 2006
      I ran into an odd problem.

      I was creating a clip to automate some reformatting I do in a file I
      receive regularly. One of the steps is to get rid of all the empty lines.

      In the old Notetab 4.x, I could do that replacing \n\n+ with \n , and it
      worked fine.

      However, when I tried to do the same in Notetab Pro 5.1, I ran into all
      sorts of weird problems.

      First, I tried to adapt the syntax to the new regexp engine, like this:

      ^!Replace "\r\n[\r\n]+" >> "\r\n" TWRAS

      No dice. Although (when ran in interactive mode) it reports replacing a
      whole bunch of stuff, in practice the file is returned exactly the same
      as it was before.

      Then I tried some variations. I tried stuff like:

      ^!Replace "\r[\r\n]+" >> "\r\n" TWRAS

      or

      ^!Replace "\r\n[\r\n]+" >> "\r" TWRAS

      or even

      ^!Replace "\r[\r\n]+" >> "\n" TWRAS

      None of them did what it was wishing for. Some did nothing, others only
      achieved partial success.


      Then I tried going around the whole thing. I replaced the \r\n string
      with an unused character (the nordic "Thorn", if you are interested -- I
      have never seen it in any of the languages I can understand), and then
      replacing the chars, like this:

      ^!Replace "^p" >> "Þ" TWAS
      ^!Replace "ÞÞ+" >> "Þ" TWRAS
      ^!Replace "Þ" >> "^p" TWAS

      That works... but I REALLY, REALLY dislike it. It's an ugly hack. I know
      that NoteTab Pro is not supposed to have problems with very long lines
      anymore, but I think NoteTab Standard/Light still do? If so, there
      should be a better way to accomplish this.

      Marcelo
    • Sheri
      I think what you want is: ^!Replace ( r n){2,} $1 WRAS (replaces all occurrences in the whole file of 2 or more r n in a row to one r n) If you prefer
      Message 2 of 4 , Nov 12, 2006
        I think what you want is:

        ^!Replace "(\r\n){2,}" >> "$1" WRAS

        (replaces all occurrences in the whole file of 2 or more \r\n in a row
        to one \r\n)

        If you prefer you could use \r\n as the replacement text. The $1 just
        substitutes the \r\n from the parentheses.

        Regards,
        Sheri
      • Marcelo de Castro Bastos
        On the last exciting episode, aired on 12/11/2006 18:39, Sheri invited ... Thanks, worked as a charm. I can t believe that the whole concept of grouping
        Message 3 of 4 , Nov 12, 2006
          On the last exciting episode, aired on 12/11/2006 18:39, Sheri invited
          the wrath of the gods by saying:
          > I think what you want is:
          >
          > ^!Replace "(\r\n){2,}" >> "$1" WRAS
          >
          >
          Thanks, worked as a charm. I can't believe that the whole concept of
          grouping slipped my mind while I was working in this...

          Marcelo
        Your message has been successfully submitted and would be delivered to recipients shortly.