in reply to expanding regexps, question with no answer yet

I don't know of any module which does that - for a very simple reason, the number of possibilites quickly explode to very large numbers.

Let's have a closer look - disregarding any Unicode issues, that would render things immediately impossible - at e.g. this regex /a/. So we are looking for a string that contains the letter 'a'. Let the maxlen be 3, a very short string.

We start out with all possible three letter strings. Every byte of the string can have (in principle) 256 different values. This gives 256**3 = 16,777,216 different strings with 3 bytes each. In turn this eats up at least (in reality it's more) 50,331,648 bytes of memory, that's nearly 50 MB! For a three letter string. Furthermore the amount of strings you will get back is huge as well - and what would you do with them ...

Ok, the problem itself is still interesting but you have to turn it down a bit - then it makes a very nice programming problem:

So go ahead and try to write the little program - and feel free to ask here if you come across some problems.

-- Hofmator

Replies are listed 'Best First'.
Re: Re: expanding regexps, question with no answer yet
by Everlasting God (Beadle) on Aug 17, 2001 at 18:58 UTC
    Thanks to magick autoincrement, there's no need to burn ram, at least on the candidate set. Of course it'll still take forver and two years on strings of any particularly interesting length.

    'The fickle fascination of and Everlasting God' - Billy Corgan, The Smashing Pumpkins

      Well, the magic autoincrement won't help too much, as it doesn't iterate over the whole range of 256 characters. Still, you are correct, you don't have to create all the possible strings in memory. Nevertheless with a regex like /./ you get to keep all possibilites so the memory problem remains. Not to mention the time issue ...

      -- Hofmator

        I was aiming more at the 'limited character set' thing with magic autoincrement, but yes, you're right. And I *did* mention the time issue. 'The fickle fascination of and Everlasting God' - Billy Corgan, The Smashing Pumpkins