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

"Find" using Regular Expressions...

Expand Messages
  • steveadausa
    Hi Everybody, I can use: ^!Find SS, SR to find lines in a text file containing the string SS, but I would also like it to be able to find lines that
    Message 1 of 12 , Aug 30, 2009
      Hi Everybody,


      I can use: ^!Find "SS," SR

      to find lines in a text file containing the string "SS,"

      but I would also like it to be able to find lines that contain "BK,", for example.

      I've tried: ^!Find "SS,|"BK," SR
      and various syntaxes using brackets, no quotes, etc etc

      but cannot get anything to work.

      Can you help me with searching for more than one string?

      Thanks,

      Steve (using NoteTab Pro 4.9)
    • John Shotsky
      When using alternation, enclose the group within parens. ^!Find (SS,| BK,) SR From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of
      Message 2 of 12 , Aug 30, 2009
        When using alternation, enclose the group within parens.
        ^!Find "(SS,|"BK,)" SR

        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of steveadausa
        Sent: Sunday, August 30, 2009 15:13
        To: ntb-clips@yahoogroups.com
        Subject: [Clip] "Find" using Regular Expressions...


        Hi Everybody,

        I can use: ^!Find "SS," SR

        to find lines in a text file containing the string "SS,"

        but I would also like it to be able to find lines that contain "BK,", for example.

        I've tried: ^!Find "SS,|"BK," SR
        and various syntaxes using brackets, no quotes, etc etc

        but cannot get anything to work.

        Can you help me with searching for more than one string?

        Thanks,

        Steve (using NoteTab Pro 4.9)



        [Non-text portions of this message have been removed]
      • steveadausa
        Thanks John. That did not work on my end. Maybe I m doing something wrong. :^( you suggested: ^!Find (SS,| BK,) SR should the quote symbol not be there
        Message 3 of 12 , Aug 30, 2009
          Thanks John.

          That did not work on my end. Maybe I'm doing something wrong. :^(

          you suggested:
          ^!Find "(SS,|"BK,)" SR

          should the quote symbol not be there before BK in that line?

          I also tried:
          ^!Find "(SS,|"BK,)" SR
          ^!Find ("SS,"|"BK,") SR
          ^!Find (SS,|BK,) SR
          ^!Find "(SS,|BK,)" SR
          ^!Find SS,|BK, SR

          and still no joy.

          Thanks, Steve
        • John Shotsky
          Yes, I did miss that, sorry. ^!Find (SS,|BK,) SR Using your Find dialog, place this in it: (SS,|BK,) Then check the case and regular expression boxes, and
          Message 4 of 12 , Aug 30, 2009
            Yes, I did miss that, sorry.
            ^!Find "(SS,|BK,)" SR
            Using your Find dialog, place this in it:
            (SS,|BK,)

            Then check the case and regular expression boxes, and then find. It should find the first one for you. It won't find the
            alternate if it finds the first one, of course. You would have to increment past the first one in order to find the next
            one. You can do that using your cursor - start with it at the top of your document, perform the find, then move the
            cursor one line past what it found, then perform the find again.

            What you are really asking with this clip is:
            Show me SS, or BK, whichever comes first.

            John

            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of steveadausa
            Sent: Sunday, August 30, 2009 15:40
            To: ntb-clips@yahoogroups.com
            Subject: Re: [Clip] "Find" using Regular Expressions...


            Thanks John.

            That did not work on my end. Maybe I'm doing something wrong. :^(

            you suggested:
            ^!Find "(SS,|"BK,)" SR

            should the quote symbol not be there before BK in that line?

            I also tried:
            ^!Find "(SS,|"BK,)" SR
            ^!Find ("SS,"|"BK,") SR
            ^!Find (SS,|BK,) SR
            ^!Find "(SS,|BK,)" SR
            ^!Find SS,|BK, SR

            and still no joy.

            Thanks, Steve



            [Non-text portions of this message have been removed]
          • steveadausa
            Thanks for your help on this, John. I am still doing something wrong, I think. I am trying to read thru a text file, and write certain lines of that file to a
            Message 5 of 12 , Aug 30, 2009
              Thanks for your help on this, John.

              I am still doing something wrong, I think.

              I am trying to read thru a text file, and write certain lines of that file to a new file.

              The source text file looks like this:
              -------------------------------------------------

              OC,OP27,N 14880.35768,E -786.44215,EL0.000,--FLY
              LS,HI4.0000,HR4.3000
              BK,OP27,BP5,BS148.4031,BC0.0004
              SS,OP27,FP28,AR77.0456,ZE89.3436,SD47.616482,--FD 1-1/2" GALV IP
              --DT08-25-2009
              --TM11:33:17
              SS,OP27,FP29,

              where I want to extract certain lines of text (containing "SS," or "BK," to new file like this:
              ------------------------------------------------------------

              BK,OP27,BP5,BS148.4031,BC0.0004
              SS,OP27,FP28,AR77.0456,ZE89.3436,SD47.616482,--FD 1-1/2" GALV IP
              SS,OP27,FP29,

              My clip works great if I search with: ^!Find "SS," SR
              and copies all of my "SS," lines to a new file, but trying to add
              "BK," to that "find" is where I fail.

              My clip:
              -----------------------------

              H="Write SS-2"
              ^!Jump DOC_START
              ^!Find "(SS,|BK,)" SR
              ^!Select Line
              ^!Menu Edit/Copy
              ^!Set %DataDoc%=^$GetDocIndex$
              ^!Menu Edit/Paste New
              ^!Set %NewDoc%=^$GetDocIndex$
              ^!Menu Document/Use as Paste Board
              ^!SetDocIndex ^%DataDoc%
              ^!Goto FIND_SS
              :FIND_SS
              ^!Find "(SS,|BK,)" SR
              ^!IfError COMPRESS2
              ^!Select Line
              ^!Menu Edit/Copy
              ^!Goto FIND_SS
              :COMPRESS2
              ^!SetDocIndex ^%NewDoc%
              ^!Menu Modify/Lines/Compress
              ^!Menu Modify/Lines/Compress
              ^!Jump DOC_START
              ^!Menu Document/Use as Paste Board
            • John Shotsky
              As I explained, it will only work with one find. Whichever one it finds first. You ll need a loop of some kind to increment through your document. If you
              Message 6 of 12 , Aug 30, 2009
                As I explained, it will only work with one find. Whichever one it finds first. You'll need a loop of some kind to
                increment through your document. If you aren't removing the strings out of the first document, then you'll always find
                the same ones as before.

                There's probably a much better way to copy strings from one document to another, but I don't have much experience with
                that, so I'll let someone else respond. I'd guess it would be done with two loops, one for each find term.
                John

                From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of steveadausa
                Sent: Sunday, August 30, 2009 16:25
                To: ntb-clips@yahoogroups.com
                Subject: Re: [Clip] "Find" using Regular Expressions...


                Thanks for your help on this, John.

                I am still doing something wrong, I think.

                I am trying to read thru a text file, and write certain lines of that file to a new file.

                The source text file looks like this:
                -------------------------------------------------

                OC,OP27,N 14880.35768,E -786.44215,EL0.000,--FLY
                LS,HI4.0000,HR4.3000
                BK,OP27,BP5,BS148.4031,BC0.0004
                SS,OP27,FP28,AR77.0456,ZE89.3436,SD47.616482,--FD 1-1/2" GALV IP
                --DT08-25-2009
                --TM11:33:17
                SS,OP27,FP29,

                where I want to extract certain lines of text (containing "SS," or "BK," to new file like this:
                ----------------------------------------------------------

                BK,OP27,BP5,BS148.4031,BC0.0004
                SS,OP27,FP28,AR77.0456,ZE89.3436,SD47.616482,--FD 1-1/2" GALV IP
                SS,OP27,FP29,

                My clip works great if I search with: ^!Find "SS," SR
                and copies all of my "SS," lines to a new file, but trying to add
                "BK," to that "find" is where I fail.

                My clip:
                -----------------------------

                H="Write SS-2"
                ^!Jump DOC_START
                ^!Find "(SS,|BK,)" SR
                ^!Select Line
                ^!Menu Edit/Copy
                ^!Set %DataDoc%=^$GetDocIndex$
                ^!Menu Edit/Paste New
                ^!Set %NewDoc%=^$GetDocIndex$
                ^!Menu Document/Use as Paste Board
                ^!SetDocIndex ^%DataDoc%
                ^!Goto FIND_SS
                :FIND_SS
                ^!Find "(SS,|BK,)" SR
                ^!IfError COMPRESS2
                ^!Select Line
                ^!Menu Edit/Copy
                ^!Goto FIND_SS
                :COMPRESS2
                ^!SetDocIndex ^%NewDoc%
                ^!Menu Modify/Lines/Compress
                ^!Menu Modify/Lines/Compress
                ^!Jump DOC_START
                ^!Menu Document/Use as Paste Board



                [Non-text portions of this message have been removed]
              • silvermoonwoman2001
                ... Instead of all that, try this. It should extract all the relevant lines and put them in a new document. ^!Set
                Message 7 of 12 , Aug 30, 2009
                  --- In ntb-clips@yahoogroups.com, "steveadausa" <steveadausa@...> wrote:
                  >
                  > I am trying to read thru a text file, and write certain lines of
                  > that file to a new file.
                  >
                  > The source text file looks like this:
                  > -------------------------------------------------
                  >
                  > OC,OP27,N 14880.35768,E -786.44215,EL0.000,--FLY
                  > LS,HI4.0000,HR4.3000
                  > BK,OP27,BP5,BS148.4031,BC0.0004
                  > SS,OP27,FP28,AR77.0456,ZE89.3436,SD47.616482,--FD 1-1/2" GALV IP
                  > --DT08-25-2009
                  > --TM11:33:17
                  > SS,OP27,FP29,
                  >
                  > where I want to extract certain lines of text (containing "SS,"
                  > or "BK," to new file like this:
                  > ------------------------------------------------------------
                  >
                  > BK,OP27,BP5,BS148.4031,BC0.0004
                  > SS,OP27,FP28,AR77.0456,ZE89.3436,SD47.616482,--FD 1-1/2" GALV IP
                  > SS,OP27,FP29,
                  >
                  > My clip works great if I search with: ^!Find "SS," SR
                  > and copies all of my "SS," lines to a new file, but trying to add
                  > "BK," to that "find" is where I fail.
                  >
                  > My clip:
                  > -----------------------------
                  >
                  > H="Write SS-2"
                  > ^!Jump DOC_START
                  > ^!Find "(SS,|BK,)" SR
                  > ^!Select Line
                  > ^!Menu Edit/Copy
                  > ^!Set %DataDoc%=^$GetDocIndex$
                  > ^!Menu Edit/Paste New
                  > ^!Set %NewDoc%=^$GetDocIndex$
                  > ^!Menu Document/Use as Paste Board
                  > ^!SetDocIndex ^%DataDoc%
                  > ^!Goto FIND_SS
                  > :FIND_SS
                  > ^!Find "(SS,|BK,)" SR
                  > ^!IfError COMPRESS2
                  > ^!Select Line
                  > ^!Menu Edit/Copy
                  > ^!Goto FIND_SS
                  > :COMPRESS2
                  > ^!SetDocIndex ^%NewDoc%
                  > ^!Menu Modify/Lines/Compress
                  > ^!Menu Modify/Lines/Compress
                  > ^!Jump DOC_START
                  > ^!Menu Document/Use as Paste Board
                  >

                  Instead of all that, try this. It should extract all the relevant lines and put them in a new document.

                  ^!Set %new%=^$GetDocListAll("^(BK|SS),.+$";"$0\r\n")$
                  ^!Toolbar New Document
                  ^!InsertText ^%new%
                  ^!ClearVariable %new%

                  Regards,
                  Sheri
                • steveadausa
                  Thanks Sheri. When I try that, I get a Line 1: Clip Syntax error . I am wondering if ^$GetDocListAll is a new command which I don t have? (I am using NTPro
                  Message 8 of 12 , Aug 30, 2009
                    Thanks Sheri.

                    When I try that, I get a "Line 1: Clip Syntax error".

                    I am wondering if ^$GetDocListAll is a new command which I don't have? (I am using NTPro 4.9, and that function does not show up in my "Help" file).

                    Thanks, Steve
                  • Alec Burgess
                    silvermoonwoman2001 (silvermoonwoman@comcast.net) wrote (in part) (on ... From Steve s first post: Steve (using NoteTab Pro 4.9) so ^$GetDocListAll()$ isn t
                    Message 9 of 12 , Aug 30, 2009
                      silvermoonwoman2001 (silvermoonwoman@...) wrote (in part) (on
                      2009-08-30 at 23:37):
                      > Instead of all that, try this. It should extract all the relevant
                      > lines and put them in a new document.
                      >
                      > ^!Set %new%=^$GetDocListAll("^(BK|SS),.+$";"$0\r\n")$
                      >
                      > ^!Toolbar New Document
                      > ^!InsertText ^%new%
                      > ^!ClearVariable %new%
                      >


                      From Steve's first post: > Steve (using NoteTab Pro 4.9) so
                      ^$GetDocListAll()$ isn't available :-(
                      Steve - If you are going to do any significant work I'd really recommend
                      getting the current Notetab 6 (at least the free-Light version).
                      Its regex engine and supporting functions are much more powerful that in
                      the 4.9x versions and make it much easier for us to help you.

                      Note - While composing this saw your next post arrive- you've already
                      discovered the problem:
                      > When I try that, I get a "Line 1: Clip Syntax error".
                      >
                      > I am wondering if ^$GetDocListAll is a new command which I don't have?
                      > (I am using NTPro 4.9, and that function does not show up in my "Help"
                      > file).

                      --
                      Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)



                      [Non-text portions of this message have been removed]
                    • steveadausa
                      Thanks Sheri. I ll check it out... -Steve
                      Message 10 of 12 , Aug 30, 2009
                        Thanks Sheri.

                        I'll check it out...

                        -Steve
                      • silvermoonwoman2001
                        ... In 4.9 each alternate needed its own parentheses. e.g.: ^!Find (SS,)|(BK,) SR probably would have done what you wanted.
                        Message 11 of 12 , Aug 31, 2009
                          --- In ntb-clips@yahoogroups.com, "steveadausa" <steveadausa@...> wrote:
                          >
                          > Hi Everybody,
                          >
                          >
                          > I can use: ^!Find "SS," SR
                          >
                          > to find lines in a text file containing the string "SS,"
                          >
                          > but I would also like it to be able to find lines that contain "BK,", for example.
                          >
                          > I've tried: ^!Find "SS,|"BK," SR
                          > and various syntaxes using brackets, no quotes, etc etc
                          >
                          > but cannot get anything to work.
                          >
                          > Can you help me with searching for more than one string?
                          >
                          > Thanks,
                          >
                          > Steve (using NoteTab Pro 4.9)
                          >

                          In 4.9 each alternate needed its own parentheses. e.g.:

                          ^!Find "(SS,)|(BK,)" SR

                          probably would have done what you wanted.
                        • steveadausa
                          Sheri, I ve upgraded, and of course your code works beautifully. Thank you so much, as I will get much use out of this. -Steve (using NoteTab Pro 6.12)
                          Message 12 of 12 , Aug 31, 2009
                            Sheri,

                            I've upgraded, and of course your code works beautifully.

                            Thank you so much, as I will get much use out of this.

                            -Steve (using NoteTab Pro 6.12)
                          Your message has been successfully submitted and would be delivered to recipients shortly.