## Re: [Clip] Regular Expression Question

Expand Messages
• ... 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 1 of 19 , Jun 4 11:43 PM
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
• ... This worked on my test file also; ^!Find (^( d d)|( d)( .)|( /) d d( .)|( /) d d) R HTH Ben
Message 2 of 19 , Jun 5 12:50 AM
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
• 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 3 of 19 , Jun 5 1:54 AM
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
• 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 4 of 19 , Jun 5 2:12 AM
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
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/

...
• Ben, Thanks, that finds it also. Larry
Message 5 of 19 , Jun 5 9:20 AM
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
• Ben, Thanks, again! Larry
Message 6 of 19 , Jun 5 9:21 AM
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
• 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 7 of 19 , Jun 5 9:23 AM
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
• 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 8 of 19 , Jun 5 9:25 AM
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
> 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/
>
>
>
>
>
>
>
> ...
• 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 9 of 19 , Jun 5 9:40 AM
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
• Very succinct regex from Hugo This should also work: ^( d+( .| /)?)+
Message 10 of 19 , Jun 5 4:03 PM
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
>
> ---------------------~--> 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/
>
>
>
>
• 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 11 of 19 , Jun 5 6:26 PM
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
• 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 12 of 19 , Jun 5 6:29 PM
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+(\.|\/)?)+
• ... Yes, but it also finds IP addresses ;)
Message 13 of 19 , Jun 5 7:00 PM
--- 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 ;)
• 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 14 of 19 , Jun 5 7:16 PM
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/
>
>
>
• 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 15 of 19 , Jun 6 4:20 PM
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 ;)
>
>
> you need to know about using SSL to encrypt your e-commerce
> http://us.click.yahoo.com/2tQ9vC/MyKEAA/sXBHAA> /dkFolB/TM
>
>
> --------------------------------------------------------------
> -------~->
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
• 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 16 of 19 , Jun 6 8:02 PM
Next year (v5.0 w/Perl) this works for dates only, not IP

>>>> ^(\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
>
> 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.