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

Re: [Clip] Regular Expression Question

Expand Messages
  • Larry Hamilton
    Hi Peter, Yes, thanks. See my other post. ... This works like I came up with in my other post. ... This does not work like above or my other post. It may be an
    Message 1 of 19 , Jun 4, 2002
    • 0 Attachment
      Hi Peter,

      Yes, thanks. See my other post.

      > Take a look in NT's help under 'Regular Expressions' and in particular
      > the section on 'Seeking Closure'. You will find that you need something
      > like this:

      This works like I came up with in my other post.

      > (^\d+\.\d+\.\d+)|(^\d+\/\d+/\d+)
      >
      > or

      This does not work like above or my other post. It may be an issue with Beta
      12. I will forward this to Eric. I could not get that to work either with
      the find dialog or the ^!Find command.

      > (^\d?\d\.\d?\d\.\d?\d)|(^\d?\d\/\d?\d/\d?\d)

      Larry
    • Ben Barnet
      ... Will this do what you want? ^!Find (^( d d)|( d) . d d . d d)|(^( d d)|( d) / d d/ d d) R HTH Ben
      Message 2 of 19 , Jun 4, 2002
      • 0 Attachment
        Larry Hamilton wrote:

        > I have come up with more ideas, but was hoping for one expression to do the
        > find/replace in one pass.
        >
        > [...] and came up with this:
        >
        > ^!Find
        > (^[0-9*]/[0-9][0-9]/[0-9][0-9])|(^[0-9][0-9]/[0-9][0-9]/[0-9][0-9])|(^\d\d\.
        > \d\d\.\d\d)|(^\d\.\d\d\.\d\d) R
        >
        > This is working well in my testing scenario, so unless I missed something,
        > this will do what I need. Of course, if there is a simpler way to do it, I
        > would like to know.

        Will this do what you want?

        ^!Find (^(\d\d)|(\d)\.\d\d\.\d\d)|(^(\d\d)|(\d)\/\d\d/\d\d) R

        HTH
        Ben
      • Ben Barnet
        ... This worked on my test file also; ^!Find (^( d d)|( d)( .)|( /) d d( .)|( /) d d) R HTH Ben
        Message 3 of 19 , Jun 5, 2002
        • 0 Attachment
          Ben Barnet wrote:

          > Will this do what you want?
          >
          > ^!Find (^(\d\d)|(\d)\.\d\d\.\d\d)|(^(\d\d)|(\d)\/\d\d/\d\d) R

          This worked on my test file also;

          ^!Find (^(\d\d)|(\d)(\.)|(\/)\d\d(\.)|(\/)\d\d) R

          HTH
          Ben
        • h.paulissen@facburfdcw.unimaas.nl
          Larry, Peter, Ben, ... Apparently there is a difference in the handling of the following (at least to me this has nothing to do with the #12 beta release since
          Message 4 of 19 , Jun 5, 2002
          • 0 Attachment
            Larry, Peter, Ben,


            >
            > > (^\d?\d\.\d?\d\.\d?\d)|(^\d?\d\/\d?\d/\d?\d)
            >

            Apparently there is a difference in the handling of the following (at least
            to me this has nothing to do with the #12 beta release since this occurs in
            my regular bversion of NoteTab as well):

            \d\d? - finds 0
            \d?\d - does not find 0

            I do not know why there is a difference...

            For what it's worth:

            I would find the date (with or without leading zero) with the following
            expression:

            ^\d+((\.|\/)\d+)+


            Regards,

            Hugo
          • Eric G.V. Fookes
            Hi Larry, ... Unfortunately, this appears to be linked to the closure problem reported earlier in beta testing. The bug is deep in the regex engine, which is
            Message 5 of 19 , Jun 5, 2002
            • 0 Attachment
              Hi Larry,

              >This does not work like above or my other post. It may be an issue with Beta
              >12. I will forward this to Eric. I could not get that to work either with
              >the find dialog or the ^!Find command.
              >
              > > (^\d?\d\.\d?\d\.\d?\d)|(^\d?\d\/\d?\d/\d?\d)

              Unfortunately, this appears to be linked to the closure problem reported
              earlier in beta testing. The bug is deep in the regex engine, which is
              developed by a third party company. There is not much I can do about this.
              I have already decided to use a different Perl-based regex engine in the
              next major release of NoteTab...


              Regards,
              Eric G.V. Fookes
              Author of NoteTab, Mailbag Assistant, and Album Express
              http://www.fookes.com/ and http://www.notetab.com/







              ...
            • lm_hamilton
              Ben, Thanks, that finds it also. Larry
              Message 6 of 19 , Jun 5, 2002
              • 0 Attachment
                Ben,

                Thanks, that finds it also.

                Larry

                --- In ntb-clips@y..., Ben Barnet <zefo@a...> wrote:
                > Will this do what you want?
                >
                > ^!Find (^(\d\d)|(\d)\.\d\d\.\d\d)|(^(\d\d)|(\d)\/\d\d/\d\d) R
                >
                > HTH
                > Ben
              • lm_hamilton
                Ben, Thanks, again! Larry
                Message 7 of 19 , Jun 5, 2002
                • 0 Attachment
                  Ben,

                  Thanks, again!

                  Larry

                  --- In ntb-clips@y..., Ben Barnet <zefo@a...> wrote:
                  > Ben Barnet wrote:
                  >
                  > > Will this do what you want?
                  > >
                  > > ^!Find (^(\d\d)|(\d)\.\d\d\.\d\d)|(^(\d\d)|(\d)\/\d\d/\d\d) R
                  >
                  > This worked on my test file also;
                  >
                  > ^!Find (^(\d\d)|(\d)(\.)|(\/)\d\d(\.)|(\/)\d\d) R
                  >
                  > HTH
                  > Ben
                • lm_hamilton
                  Hugo, Peter, Ben, Thanks for all the tips. I now have 5 reg exps that do what I want. I have not done much with them before, but this is one situation that a
                  Message 8 of 19 , Jun 5, 2002
                  • 0 Attachment
                    Hugo, Peter, Ben,

                    Thanks for all the tips. I now have 5 reg exps that do what I want. I
                    have not done much with them before, but this is one situation that a
                    reg exp is much simpler than all the ways a clip would have to do it.

                    Larry

                    --- In ntb-clips@y..., h.paulissen@f... wrote:
                    > Larry, Peter, Ben,
                    >
                    >
                    > >
                    > > > (^\d?\d\.\d?\d\.\d?\d)|(^\d?\d\/\d?\d/\d?\d)
                    > >
                    >
                    > Apparently there is a difference in the handling of the following
                    (at least
                    > to me this has nothing to do with the #12 beta release since this
                    occurs in
                    > my regular bversion of NoteTab as well):
                    >
                    > \d\d? - finds 0
                    > \d?\d - does not find 0
                    >
                    > I do not know why there is a difference...
                    >
                    > For what it's worth:
                    >
                    > I would find the date (with or without leading zero) with the
                    following
                    > expression:
                    >
                    > ^\d+((\.|\/)\d+)+
                    >
                    >
                    > Regards,
                    >
                    > Hugo
                  • lm_hamilton
                    Hi Eric, I sort of figured that. I just wanted to make sure you were aware of it, in the off chance there was something you could do. At least I have at least
                    Message 9 of 19 , Jun 5, 2002
                    • 0 Attachment
                      Hi Eric,

                      I sort of figured that. I just wanted to make sure you were aware of
                      it, in the off chance there was something you could do. At least I
                      have at least 5 reg exps that will do what I want out of all this.

                      Larry

                      --- In ntb-clips@y..., "Eric G.V. Fookes" <egroups@f...> wrote:
                      > Hi Larry,
                      >
                      > >This does not work like above or my other post. It may be an issue
                      with Beta
                      > >12. I will forward this to Eric. I could not get that to work
                      either with
                      > >the find dialog or the ^!Find command.
                      > >
                      > > > (^\d?\d\.\d?\d\.\d?\d)|(^\d?\d\/\d?\d/\d?\d)
                      >
                      > Unfortunately, this appears to be linked to the closure problem
                      reported
                      > earlier in beta testing. The bug is deep in the regex engine, which
                      is
                      > developed by a third party company. There is not much I can do
                      about this.
                      > I have already decided to use a different Perl-based regex engine
                      in the
                      > next major release of NoteTab...
                      >
                      >
                      > Regards,
                      > Eric G.V. Fookes
                      > Author of NoteTab, Mailbag Assistant, and Album Express
                      > http://www.fookes.com/ and http://www.notetab.com/
                      >
                      >
                      >
                      >
                      >
                      >
                      >
                      > ...
                    • silvermoonwoman2001
                      Hi guys, I think when using a regex pattern that can find zero occurrences of something it needs to be found next to something more definite. So to me it
                      Message 10 of 19 , Jun 5, 2002
                      • 0 Attachment
                        Hi guys,

                        I think when using a regex pattern that can find zero occurrences of
                        something it needs to be found next to something more definite. So
                        to me it makes sense that "\d?" by itself won't find anything,
                        while "\d\d?" finds one or two adjacent digits.

                        I just tested "\d?\d" and discovered it finds two (and only two)
                        adjacent digits, which comes as a surprise to me. If it were
                        evaluated from left to right, the \d? would make it find neither one
                        nor two adjacent digits and it would just fail outright.

                        I didn't know a "^" could be used inside parentheses. Seems to work
                        tho.

                        Sheri

                        --- In ntb-clips@y..., h.paulissen@f... wrote:
                        > Larry, Peter, Ben,
                        >
                        >
                        > >
                        > > > (^\d?\d\.\d?\d\.\d?\d)|(^\d?\d\/\d?\d/\d?\d)
                        > >
                        >
                        > Apparently there is a difference in the handling of the following
                        (at least
                        > to me this has nothing to do with the #12 beta release since this
                        occurs in
                        > my regular bversion of NoteTab as well):
                        >
                        > \d\d? - finds 0
                        > \d?\d - does not find 0
                        >
                        > I do not know why there is a difference...
                        >
                        > For what it's worth:
                        >
                        > I would find the date (with or without leading zero) with the
                        following
                        > expression:
                        >
                        > ^\d+((\.|\/)\d+)+
                        >
                        >
                        > Regards,
                        >
                        > Hugo
                      • Peter Stagg
                        Very succinct regex from Hugo This should also work: ^( d+( .| /)?)+
                        Message 11 of 19 , Jun 5, 2002
                        • 0 Attachment
                          Very succinct regex from Hugo

                          This should also work:

                          ^(\d+(\.|\/)?)+


                          > -----Original Message-----
                          > From: h.paulissen@...
                          > [mailto:h.paulissen@...]
                          > Sent: Wednesday, 5 June 2002 6:55 PM
                          > To: ntb-clips@yahoogroups.com
                          > Subject: RE: [Clip] Regular Expression Question
                          >
                          >
                          > Larry, Peter, Ben,
                          >
                          >
                          > >
                          > > > (^\d?\d\.\d?\d\.\d?\d)|(^\d?\d\/\d?\d/\d?\d)
                          > >
                          >
                          > Apparently there is a difference in the handling of the
                          > following (at least to me this has nothing to do with the #12
                          > beta release since this occurs in my regular bversion of
                          > NoteTab as well):
                          >
                          > \d\d? - finds 0
                          > \d?\d - does not find 0
                          >
                          > I do not know why there is a difference...
                          >
                          > For what it's worth:
                          >
                          > I would find the date (with or without leading zero) with the
                          > following
                          > expression:
                          >
                          > ^\d+((\.|\/)\d+)+
                          >
                          >
                          > Regards,
                          >
                          > Hugo
                          >
                          > ------------------------ Yahoo! Groups Sponsor
                          > ---------------------~--> Tied to your PC? Cut Loose and Stay
                          > connected with Yahoo! Mobile
                          > http://us.click.yahoo.com/QBCcSD/o1CEAA/sXBHAA> /dkFolB/TM
                          >
                          >
                          > --------------------------------------------------------------
                          > -------~->
                          >
                          >
                          >
                          > Your use of Yahoo! Groups is subject to
                          > http://docs.yahoo.com/info/terms/
                          >
                          >
                          >
                          >
                        • Larry Hamilton
                          Sherri, ... I was not clear on this either. I find that part of working with the regexp engine in NoteTab is more trial and error than I would like. I am not
                          Message 12 of 19 , Jun 5, 2002
                          • 0 Attachment
                            Sherri,

                            > I didn't know a "^" could be used inside parentheses. Seems to work
                            > tho.

                            I was not clear on this either. I find that part of working with the regexp
                            engine in NoteTab is more trial and error than I would like. I am not sure
                            if it is me, or if I need better explanation in help, or more examples.

                            It is sort of like calculus way back in college, I understood the examples
                            in class and in the book, but there was never an example like the complexity
                            of the homework problems. This whole thread has really helped, especially
                            since it is a real-world problem.

                            Larry
                          • Larry Hamilton
                            Peter, Thanks! Now there are six reg exps for what I want. That s a different challenge, who has the shortest? ;-) Larry ... From: Peter Stagg
                            Message 13 of 19 , Jun 5, 2002
                            • 0 Attachment
                              Peter,

                              Thanks! Now there are six reg exps for what I want.

                              That's a different challenge, who has the shortest? ;-)

                              Larry

                              ----- Original Message -----
                              From: "Peter Stagg" <peter.stagg@...>
                              To: <ntb-clips@yahoogroups.com>
                              Sent: Wednesday, June 05, 2002 7:03 PM
                              Subject: RE: [Clip] Regular Expression Question


                              > Very succinct regex from Hugo
                              >
                              > This should also work:
                              >
                              > ^(\d+(\.|\/)?)+
                            • silvermoonwoman2001
                              ... Yes, but it also finds IP addresses ;)
                              Message 14 of 19 , Jun 5, 2002
                              • 0 Attachment
                                --- In ntb-clips@y..., "Larry Hamilton" <lmh@h...> wrote:

                                > > Very succinct regex from Hugo
                                > >
                                > > This should also work:
                                > >
                                > > ^(\d+(\.|\/)?)+

                                Yes, but it also finds IP addresses ;)
                              • Larry Hamilton
                                Sherri, Yes I tried, and both Hugo s and Peter s regexps do find IP addresses. They both also appear to find any pattern of numbers separated by periods. Try
                                Message 15 of 19 , Jun 5, 2002
                                • 0 Attachment
                                  Sherri,

                                  Yes I tried, and both Hugo's and Peter's regexps do find IP addresses.

                                  They both also appear to find any pattern of numbers separated by periods.

                                  Try them on this string:


                                  169123.59.23.10.99.23.343

                                  Larry

                                  ----- Original Message -----
                                  From: "silvermoonwoman2001" <silvermoonwoman@...>
                                  To: <ntb-clips@yahoogroups.com>
                                  Sent: Wednesday, June 05, 2002 10:00 PM
                                  Subject: Re: [Clip] Regular Expression Question


                                  > --- In ntb-clips@y..., "Larry Hamilton" <lmh@h...> wrote:
                                  >
                                  > > > Very succinct regex from Hugo
                                  > > >
                                  > > > This should also work:
                                  > > >
                                  > > > ^(\d+(\.|\/)?)+
                                  >
                                  > Yes, but it also finds IP addresses ;)
                                  >
                                  >
                                  >
                                  >
                                  >
                                  > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
                                  >
                                  >
                                  >
                                • Peter Stagg
                                  1) Yes, but only at the beginning of a line. 2) LH want s a regex to find dates at the beginning of a line and if he knows his files do not contain any other
                                  Message 16 of 19 , Jun 6, 2002
                                  • 0 Attachment
                                    1) Yes, but only at the beginning of a line.
                                    2) LH want's a regex to find dates at the beginning of a line and if he
                                    knows his files do not contain any other strings of this kind at the
                                    beginning of a line then great.
                                    4) Yes, it also finds IP addresses! - reusable code!
                                    5) That's regex - it can be both a no.10 spanner and a monkey wrench -
                                    both will turn a no.10 nut but one will also turn a no.14 nut - depends
                                    how accurate you want to be and as NTs regex is not as advanced as say
                                    Perl's or others that have closures such that you can state exact
                                    numbers of items you want to find, I find the simpler more elegant
                                    solutions have to be a bit of a loose fit.

                                    > -----Original Message-----
                                    > From: silvermoonwoman2001 [mailto:silvermoonwoman@...]
                                    > Sent: Thursday, 6 June 2002 12:00 PM
                                    > To: ntb-clips@yahoogroups.com
                                    > Subject: Re: [Clip] Regular Expression Question
                                    >
                                    >
                                    > --- In ntb-clips@y..., "Larry Hamilton" <lmh@h...> wrote:
                                    >
                                    > > > Very succinct regex from Hugo
                                    > > >
                                    > > > This should also work:
                                    > > >
                                    > > > ^(\d+(\.|\/)?)+
                                    >
                                    > Yes, but it also finds IP addresses ;)
                                    >
                                    >
                                    > ------------------------ Yahoo! Groups Sponsor
                                    > ---------------------~--> Download VeriSign's FREE guide,
                                    > "Securing Your Web Site for Business" and learn everything
                                    > you need to know about using SSL to encrypt your e-commerce
                                    > transactions for serious online security. Click here!
                                    > http://us.click.yahoo.com/2tQ9vC/MyKEAA/sXBHAA> /dkFolB/TM
                                    >
                                    >
                                    > --------------------------------------------------------------
                                    > -------~->
                                    >
                                    >
                                    >
                                    > Your use of Yahoo! Groups is subject to
                                    > http://docs.yahoo.com/info/terms/
                                    >
                                    >
                                    >
                                    >
                                  • Alec Burgess
                                    Next year (v5.0 w/Perl) this works for dates only, not IP addresses) Right? ... should match: 05.1.3 words ... 05/06/83 words ... and maybe(not sure how this
                                    Message 17 of 19 , Jun 6, 2002
                                    • 0 Attachment
                                      Next year (v5.0 w/Perl) this works for dates only, not IP
                                      addresses) Right?

                                      >>>> ^(\d{1,2)(\.|\/)?){3}/w

                                      should match:
                                      05.1.3 words ...
                                      05/06/83 words ...

                                      and maybe(not sure how this would parse):
                                      030498 or this
                                      123 words ...

                                      but not
                                      1.3.4.6 words ...

                                      or do I have round and curly brackets reversed?

                                      Regards ... Alec

                                      ---- Original Message ----
                                      From: "Larry Hamilton" <lmh@...>
                                      To: <ntb-clips@yahoogroups.com>
                                      Sent: 05 June, 2002 22:16
                                      Subject: Re: [Clip] Regular Expression Question

                                      > Sherri,
                                      >
                                      > Yes I tried, and both Hugo's and Peter's regexps do
                                      find
                                      > IP addresses.
                                      >
                                      > They both also appear to find any pattern of numbers
                                      > separated by periods.
                                      >
                                      > Try them on this string:
                                      >
                                      >
                                      > 169123.59.23.10.99.23.343
                                      >
                                      > Larry
                                      >
                                      > ----- Original Message -----
                                      > From: "silvermoonwoman2001"
                                      <silvermoonwoman@...>
                                      > To: <ntb-clips@yahoogroups.com>
                                      > Sent: Wednesday, June 05, 2002 10:00 PM
                                      > Subject: Re: [Clip] Regular Expression Question
                                      >
                                      >
                                      >> --- In ntb-clips@y..., "Larry Hamilton" <lmh@h...>
                                      wrote:
                                      >>
                                      >>>> Very succinct regex from Hugo
                                      >>>>
                                      >>>> This should also work:
                                      >>>>
                                      >>>> ^(\d+(\.|\/)?)+
                                      >>
                                      >> Yes, but it also finds IP addresses ;)
                                      >>
                                    Your message has been successfully submitted and would be delivered to recipients shortly.