Hint: #3 is just as easy as #1 and #2. || || || || \/ $string =~ /^[^a]*(a*)[^a]*\1[^a]*$/ && $string =~ /^[^b]*b[^b]*(b*)[^b]*\1[^b]*$/ -----Original Message----- From: Rich Morin [mailto:rdm@cfcl.com] Sent: Wednesday, September 08, 1999 11:27 AM To: fwp@technofile.org Subject: [FWP] counting in REs 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... -r -- Rich Morin: rdm@cfcl.com, +1 650-873-7841, http://www.ptf.com/~rdm Prime Time Freeware: info@ptf.com, +1 408-433-9662, http://www.ptf.com MacPerl: http://www.macperl.com, http://www.ptf.com/ptf/products/MPPE MkLinux: http://www.mklinux.apple.com, http://www.ptf.com/ptf/products/MKLP ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe ********************************************************************** This e-mail is intended only for the addressee named above. As this e-mail may contain confidential or privileged information, if you are not the named addressee, you are not authorised to retain, read, copy or disseminate this message or any part of it. ************************************************************************ ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe