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

Re: [FWP] counting in REs



On Wed, Sep 08, 1999 at 12:04:19PM -0400, WORENKLEIN, David, GCM wrote:
> Hint: #3 is just as easy as #1 and #2.
> 
>  ||
>  ||
>  ||
>  ||
>  \/
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> $string =~ /^[^a]*(a*)[^a]*\1[^a]*$/ && $string =~
> /^[^b]*b[^b]*(b*)[^b]*\1[^b]*$/
> 

I see three things wrong with this solution...

1) It uses two regular expressions, not a regular expression.  I think the
   singular is an important part of the problem statement.

2) It uses back-references, so the expressions aren't really regular.

3) It just doesn't work.  '--a--a--a--a--' clearly has an even number of
   'a's, but is not matched by the first regex.

:)

Ronald

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