> A friend of mine recently presented me with three cases to match with > a regular expression: > > 1) test for an even number of 'a's in a string > > 2) test for an odd number of 'b's in a string > > 3) test for an even number of 'a's > and an odd number of 'b's in a string > > Tasks 1 and 2 are pretty easy. Task 3, however, is rather tricky. I > will post some possible approaches in a followup... Spoiler space: I haven't seen a followup yet, so I'll throw out this as a starting point for #3: /^[^ab]* # Leading trash (a[^ab]*a[^ab]*| # Discard aa b[^ab]*b[^ab]*| # Discard bb a[^ab]*b[^ab]*a[^ab]*b[^ab]*| # Discard abab b[^ab]*a[^ab]*b[^ab]*a[^ab]*| # Discard baba a[^ab]*b[^ab]*b[^ab]*a[^ab]*| # Discard abba b[^ab]*a[^ab]*a[^ab]*b[^ab]*) # Discard baab b[^ab]*$/x # Find final b This is obviously extremely brute force. -- Boyd Nation Energy Management Systems Services Southern Company boyd@emss.com (205) 257-5789 FAX: (205) 257-3689 ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe