> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] > Sent: Wednesday, February 13, 2008 1:41 PM > To: python-list@python.org > Subject: Re: Regular Expression for Prime Numbers (or How I came to > fail at them, and love the bomb) > > On Feb 13, 9:48 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > > On Wed, 2008-02-13 at 07:31 -0800, [EMAIL PROTECTED] wrote: > > > return re.match("^1?$|^(11+?)\1+$", convert) > > > > That needs to be either > > > > return re.match(r"^1?$|^(11+?)\1+$", convert) > > > > or > > > > return re.match("^1?$|^(11+?)\\1+$", convert) > > > > in order to prevent "\1" from being read as "\x01". > > But why doesn't it work when you make that change?
It does work. Read the referenced website. If there is a match then the number isn't prime else # no match the number is prime. ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622 -- http://mail.python.org/mailman/listinfo/python-list