Re: Generating all permutations from a regexp

2006-12-25 Thread BJörn Lindqvist
On 23 Dec 2006 04:23:09 -0800, Chris Johnson <[EMAIL PROTECTED]> wrote: > > BJörn Lindqvist wrote: > > With regexps you can search for strings matching it. For example, > > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > > do the reverse, from a regexp generate all strings th

Re: Generating all permutations from a regexp

2006-12-25 Thread Paul McGuire
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Dec 22, 8:30 am, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > With regexps you can search for strings matching it. For example, > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > do the reverse,

Re: Generating all permutations from a regexp

2006-12-25 Thread BJörn Lindqvist
With some help from the sre_parse module (and the Python Cookbook), here is the completed module: # -*- coding: utf-8 -*- import itertools from sre_constants import * import sre_parse import string category_chars = { CATEGORY_DIGIT : string.digits, CATEGORY_SPACE : string.whitespace,

Re: Generating all permutations from a regexp

2006-12-25 Thread BJörn Lindqvist
On 12/22/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > BJörn Lindqvist wrote: > > With regexps you can search for strings matching it. For example, > > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > > do the reverse, from a regexp generate all strings that could match > > i

Re: Generating all permutations from a regexp

2006-12-23 Thread Chris Johnson
Thomas Ploch wrote: > Fredrik Lundh wrote: > > Nick Craig-Wood wrote: > > > >> A regular expression matcher uses a state machine to match strings. > > > > unless it's the kind of regular expression matcher that doesn't use a > > state machine, like the one in Python. > > > > > > > > How is the ma

Re: Generating all permutations from a regexp

2006-12-23 Thread Thomas Ploch
Fredrik Lundh wrote: > Nick Craig-Wood wrote: > >> A regular expression matcher uses a state machine to match strings. > > unless it's the kind of regular expression matcher that doesn't use a > state machine, like the one in Python. > > > How is the matching engine implemented then? I thou

Re: Generating all permutations from a regexp

2006-12-23 Thread Chris Johnson
BJörn Lindqvist wrote: > With regexps you can search for strings matching it. For example, > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > do the reverse, from a regexp generate all strings that could match > it. > > The regexp: "[A-Z]{3}\d{3}" should generate the strings

Re: Generating all permutations from a regexp

2006-12-22 Thread Nick Craig-Wood
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > > A regular expression matcher uses a state machine to match strings. > > unless it's the kind of regular expression matcher that doesn't use a > state machine, like the one in Python. Ah! Well that is outside of my exper

Re: Generating all permutations from a regexp

2006-12-22 Thread Paul McGuire
On Dec 22, 8:30 am, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > With regexps you can search for strings matching it. For example, > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > do the reverse, from a regexp generate all strings that could match > it. > > The regexp: "[

Re: Generating all permutations from a regexp

2006-12-22 Thread Fredrik Lundh
Nick Craig-Wood wrote: > A regular expression matcher uses a state machine to match strings. unless it's the kind of regular expression matcher that doesn't use a state machine, like the one in Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating all permutations from a regexp

2006-12-22 Thread Nick Craig-Wood
BJörn Lindqvist <[EMAIL PROTECTED]> wrote: > With regexps you can search for strings matching it. For example, > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > do the reverse, from a regexp generate all strings that could match > it. > > The regexp: "[A-Z]{3}\d{3}" sho

Re: Generating all permutations from a regexp

2006-12-22 Thread Fredrik Lundh
BJörn Lindqvist wrote: > With regexps you can search for strings matching it. For example, > given the regexp: "foobar\d\d\d". "foobar123" would match. I want to > do the reverse, from a regexp generate all strings that could match > it. > > The regexp: "[A-Z]{3}\d{3}" should generate the strings