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

Re: [FWP] counting in REs



On Wed, Sep 08, 1999 at 09:35:20AM -0700, Rich Morin wrote:
> At 12:04 PM -0400 9/8/99, WORENKLEIN, David, GCM wrote:
> >Hint: #3 is just as easy as #1 and #2.
> 
> Ahem.  This is _almost_ the approach I suggested; here's mine:
> 
>    $string =~       /^[^a]*(a[^a]*a)*[^a]*$/ &&
>    $string =~ /^[^b]*b[^b]*(b[^b]*b)*[^b]*$/;

That fails on the same string I presented for David's regex:
'--a--a--a--a--'
because it requires adjacent 'a's.

    $string =~       /^[^a]*(a[^a]*a[^a]*)*$/ &&
    $string =~ /^[^b]*b[^b]*(b[^b]*b[^b]*)*$/;


Ronald

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