Regular Expression for Prime Numbers (or How I came to fail at them, and love the bomb)
castironpi at gmail.com
castironpi at gmail.com
Wed Feb 13 17:14:57 EST 2008
On Feb 13, 9:48 am, Carsten Haese <cars... at uniqsys.com> wrote:
> On Wed, 2008-02-13 at 07:31 -0800, cokofree... at gmail.com 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".
>
> --
> Carsten Haesehttp://informixdb.sourceforge.net
re.match(r"^(oo+?)\1+$", 'o'*i ) drops i in [0,1]
and
re.match(r"^(ooo+?)\1+$", 'o'*i ), which only drops i in [0,1,4].
Isn't the finite state machine "regular expression 'object'" really
large?
More information about the Python-list
mailing list