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

Re: [Clip] How to invoke a clip

Expand Messages
  • flo.gehrke
    ... Don, Bruce, ... It s difficult to write a solution without knowing the data. So we may start with the following approach. I think there possibly are also
    Message 1 of 33 , Nov 24, 2009
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@...> wrote:
      >
      > like: 72.29.92.97
      > try
      >
      > ^\d\d\.\d\d\.\d\d\.\d\d\.
      > or
      > ^\d{2}\.\d{2}\.\d{2}\.\d{2}
      > or even
      > ^(\d{2}\.)(?1)(?1)(\d{2})
      > However this won't work with the replace ... Flo?

      Don, Bruce,

      > always begin with an IP-address. I would like to insert a CRLF
      > before each entry. How would you check to see if the first
      > string on a line contains only digits and exactly 3 periods
      > (full stops)? I would then insert a CRLF. I would of course,
      > risk doing that with a line that merely appears to begin with
      > an IP-address

      It's difficult to write a solution without knowing the data. So we may start with the following approach. I think there possibly are also adresses with 1- and 3-digit-numbers separated with period -- isn't it?

      The following clip inserts a CRNL at the beginning of every line which, from start to end of line, contains nothing but an IP-address. But it omits any line which starts with an IP-address that is followed by anything else till the end of line.

      I've written it in Extended Mode so one could better see the subpatterns (one long line!):

      ^!Replace "(?x) ^ (?= (?: (\d{1,3}\.){3} \d{1,3}) $)" >> "\r\n" AWRS

      When matched against the following lines a CRNL will be inserted before all lines except the one with "Hallo world".

      72.29.92.97
      72.29.92.97 Hallo world
      55.444.01.3
      722.239.942.967

      Tested with NT Pro 6.12

      Regards,
      Flo
    • John B Shotsky
      Since I get files from the interenet, and have no idea of the CRLF format of received files, I always use R to detect any form of single or double characters,
      Message 33 of 33 , Nov 27, 2009
      • 0 Attachment
        Since I get files from the interenet, and have no idea of the CRLF format of
        received files, I always use \R to detect any form of single or double
        characters, and replace with \r\n so that I know that whatever form is in
        the text, my replacement will be successful.

        So
        ^!Replace "\R" >> "\r\n" ARTSW
        provides that all forms of CRLF or CR or LF or LFCR are replaced with one
        known entitiy. Then, throughout my libraries, I continue to use \R to detect
        any form of line end. If I want to remove only excess blank lines, but
        retain them between paragraphs, I use
        ^!Replace "\R\R+" >> "\r\n\r\n" ARTSW
        John

        > > Regarding your latest sample data, it appears to be dispensable
        > > to search for complete IP-adresses. The only numbers at the start
        > > of any line (or paragraph) are IP-adresses.
        >
        >Yes, and then the unexpected happens. I've found it pays to make
        >searches as specific as reasonable possible. For me this means looking
        >for four number groups because this is quick and easy and not checking
        >the ranges for 254 or less, as that makes it too complicated to be worth
        >it. No hard rules here, but more specific is better.

        > Yes, I heartily concur! It is much easier to overkill the criteria and
        > error
        > messages than debug obscure coding errors.
        >
        >
        > > > To actually delete empty lines only you have to write...
        > > > ^!If ^$GetLineSize$ > 0 Skip
        > > > ^!DeleteLine
        > >
        > >I wasn't sure if CR LF were counted as two characters or not and too
        > >lazy to try. As they're not, you're right and this is an example of more
        > >specific being better: A line with just one or two characters may be
        > >improbable but it is possible.
        >
        > Actually, the CRLF sequence IS two characters which you can verify
        > by creating a new doc with two or more blank lines and running this clip:
        >
        > ^!Jump Doc_Start
        > ^!Select +2
        >
        > Only one line is selected. If the CRLF was only one character, 2 lines
        > would be selected. If you try selecting just 1 character, nothing is
        > selected.
        >
        > Unsing the adage "If it works, don't fix it", I have been using this
        > snippet
        > to delete an empty line:
        >
        > ^!Select +2
        > ^!Replace "^P" >> "" HS
        >
        > But with the ideas brought out in this thread and my strong preference
        > for non-crossing flow chart lines (a la Nassi-Shneiderman diagrams) and
        > to make the code more readable, I will now use this snippet:
        >
        > ^!If ^$GetLineSize$ = 0 ^!DeleteLine
        >
        > Thanks,
        >
        > Namaste', Art
        >
        > ----------
        >
        > No virus found in this outgoing message.
        >
        > Checked by AVG - www.avg.com
        > Version: 9.0.709 / Virus Database: 270.14.84/2530 - Release Date: 11/26/09
        > 23:58:00
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >


        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.