[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] counting in REs



On Wed, Sep 08, 1999 at 10:40:55AM -0700, Rich Morin wrote:
> At 1:23 PM -0400 9/8/99, Ronald J Kimball wrote:
> >Yes, it does; it requires adjacent 'a's if there are more than 2 'a's.
> >The second and third 'a' must be adjacent, the fourth and fifth 'a', etc.
> 
> I don't see this, and neither does my test harness.  Running just the
> first half of the test:
> 
>    for (;;) {
>      print 'Next? ';
>      $string = <>;
>      chop $string;
>      if ($string =~ /^[^a]*(a[^a]*a[^a]*)*$/)  {
>        print "pass ($string)\n\n";
>      } else {
>        print "fail ($string)\n\n";
>      }
>    }

That's because your test harness is using the corrected version of the
regex that I provided.

Your regex:  /^[^a]*(a[^a]*a)*[^a]*$/
My regex:    /^[^a]*(a[^a]*a[^a]*)*$/

Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe