Re: How to print all expressions that match a regular expression

2010-02-08 Thread Gabriel Genellina
En Mon, 08 Feb 2010 02:17:59 -0300, hzh...@gmail.com escribió: Please check out this example on the pyparsing wiki, invRegex.py:http://pyparsing.wikispaces.com/file/view/invRegex.py. This code implements a generator that returns successive matching strings for the given regex. [...] Of co

Re: How to print all expressions that match a regular expression

2010-02-08 Thread Gabriel Genellina
En Mon, 08 Feb 2010 02:17:59 -0300, hzh...@gmail.com escribió: Please check out this example on the pyparsing wiki, invRegex.py:http://pyparsing.wikispaces.com/file/view/invRegex.py. This code implements a generator that returns successive matching strings for the given regex. [...] Of co

Re: How to print all expressions that match a regular expression

2010-02-07 Thread hzh...@gmail.com
> > Please check out this example on the pyparsing wiki, > invRegex.py:http://pyparsing.wikispaces.com/file/view/invRegex.py.  This code > implements a generator that returns successive matching strings for > the given regex.  Running it, I see that you actually have a typo in > your example. > >

Re: How to print all expressions that match a regular expression

2010-02-07 Thread Paul McGuire
On Feb 6, 1:36 pm, "hzh...@gmail.com" wrote: > Hi, > > I am a fresh man with python. I know there is regular expressions in > Python. What I need is that given a particular regular expression, > output all the matches. For example, given “[1|2|3]{2}” as the regular > expression, the program should

Re: How to print all expressions that match a regular expression

2010-02-07 Thread Steven D'Aprano
On Sun, 07 Feb 2010 20:19:53 -0500, Steve Holden wrote: > Steven D'Aprano wrote: >> On Sun, 07 Feb 2010 03:53:49 +0100, Alf P. Steinbach wrote: >> "Given the function hashlib.sha256, enumerate all the possible inputs that give the hexadecimal result 0a2591aaf3340ad92faecbc5908e74d0

Re: How to print all expressions that match a regular expression

2010-02-07 Thread Steve Holden
Steven D'Aprano wrote: > On Sun, 07 Feb 2010 03:53:49 +0100, Alf P. Steinbach wrote: > >>> "Given the function hashlib.sha256, enumerate all the possible inputs >>> that give the hexadecimal result >>> 0a2591aaf3340ad92faecbc5908e74d04b51ee5d2deee78f089f1607570e2e91." >> I tried some "parrot" vari

Re: How to print all expressions that match a regular expression

2010-02-07 Thread Steven D'Aprano
On Sun, 07 Feb 2010 03:53:49 +0100, Alf P. Steinbach wrote: >> "Given the function hashlib.sha256, enumerate all the possible inputs >> that give the hexadecimal result >> 0a2591aaf3340ad92faecbc5908e74d04b51ee5d2deee78f089f1607570e2e91." > > I tried some "parrot" variants but no dice. :-( Oh, e

Re: How to print all expressions that match a regular expression

2010-02-07 Thread hzh...@gmail.com
That is a method called brute force. According to my computation, 2^2048= 32317006071311007300714876688669951960444102669715484032130345427524655138867890 89319720141152291346368871796092189801949411955915049092109508815238644828312063 087736730099609175019775038965210679605763838406756827679221864

Re: How to print all expressions that match a regular expression

2010-02-07 Thread Steve Holden
hzh...@gmail.com wrote: >> And I really don't see how simple enumeration of range(2^2048) breaks >> RSA-2048, since that problem requires you to find two factors which, >> when multiplied together, give that specific value. >> > > I can tell you why is that. RSA-2048 has a composite of length less

Re: How to print all expressions that match a regular expression

2010-02-07 Thread hzh...@gmail.com
> > And I really don't see how simple enumeration of range(2^2048) breaks > RSA-2048, since that problem requires you to find two factors which, > when multiplied together, give that specific value. > I can tell you why is that. RSA-2048 has a composite of length less than 2^2048, which is a prod

Re: How to print all expressions that match a regular expression

2010-02-07 Thread Tim Chase
hzh...@gmail.com wrote: "Given the function hashlib.sha256, enumerate all the possible inputs that give the hexadecimal result 0a2591aaf3340ad92faecbc5908e74d04b51ee5d2deee78f089f1607570e2e91." This is a hash collision problem. Nobody has proved that SHA-256 is collision free It's actually pr

Re: How to print all expressions that match a regular expression

2010-02-07 Thread Steve Holden
hzh...@gmail.com wrote: >> So it seems we both misunderstood the problem. >> >> I didn't read the top level article until now, and reading it, I can't make >> sense of it. >> > > Seems that you should read the whole thing before making a post, or > else you cannot know what we are talking about. >

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Nobody
On Sun, 07 Feb 2010 00:26:36 +, Steven D'Aprano wrote: >> So there isn't such a routine just because some of the regular >> expressions cannot be enumerated. No. There isn't a routine because no-one has yet felt any need to write one. >> However, some of them can be >> enumerated. I guess I

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Alf P. Steinbach
* hzh...@gmail.com: So it seems we both misunderstood the problem. I didn't read the top level article until now, and reading it, I can't make sense of it. [1] Seems that you should read the whole thing before making a post, or else you cannot know what we are talking about. Steven doesn't mi

Re: How to print all expressions that match a regular expression

2010-02-06 Thread hzh...@gmail.com
> > So it seems we both misunderstood the problem. > > I didn't read the top level article until now, and reading it, I can't make > sense of it. > Seems that you should read the whole thing before making a post, or else you cannot know what we are talking about. Steven doesn't misunderstand me.

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Alf P. Steinbach
* Steven D'Aprano: On Sun, 07 Feb 2010 01:51:19 +0100, Alf P. Steinbach wrote: Regular expressions are programs in a "regex" programming language. What you are asking for is the same as saying: "Is there a program that can enumerate every possible set of data that is usable as valid input for

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Grant Edwards
On 2010-02-06, Roy Smith wrote: >> I am a fresh man with python. I know there is regular expressions in >> Python. What I need is that given a particular regular expression, >> output all the matches. [..] > Please enumerate all the strings which match ".*". Use additional sheets > of paper if

Re: How to print all expressions that match a regular expression

2010-02-06 Thread MRAB
Alf P. Steinbach wrote: * Steven D'Aprano: On Sat, 06 Feb 2010 16:05:15 -0800, hzh...@gmail.com wrote: Thanks for your reply. So there isn't such a routine just because some of the regular expressions cannot be enumerated. However, some of them can be enumerated. I guess I have to write a func

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Steven D'Aprano
On Sun, 07 Feb 2010 01:51:19 +0100, Alf P. Steinbach wrote: >> Regular expressions are programs in a "regex" programming language. >> What you are asking for is the same as saying: >> >> "Is there a program that can enumerate every possible set of data that >> is usable as valid input for a given

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Alf P. Steinbach
* Steven D'Aprano: On Sat, 06 Feb 2010 16:05:15 -0800, hzh...@gmail.com wrote: Thanks for your reply. So there isn't such a routine just because some of the regular expressions cannot be enumerated. However, some of them can be enumerated. I guess I have to write a function myself. How do you

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Steven D'Aprano
On Sat, 06 Feb 2010 16:05:15 -0800, hzh...@gmail.com wrote: > Thanks for your reply. > So there isn't such a routine just because some of the regular > expressions cannot be enumerated. However, some of them can be > enumerated. I guess I have to write a function myself. How do you expect to tell

Re: How to print all expressions that match a regular expression

2010-02-06 Thread hzh...@gmail.com
Thanks for your reply. So there isn't such a routine just because some of the regular expressions cannot be enumerated. However, some of them can be enumerated. I guess I have to write a function myself. Zhuo On Feb 6, 5:23 pm, Roy Smith wrote: > In article > , > > > > > >  "hzh...@gmail.com" w

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Ben Finney
Roy Smith writes: > "hzh...@gmail.com" wrote: > > What I need is that given a particular regular expression, output > > all the matches. […] > Please enumerate all the strings which match ".*". Use additional > sheets of paper if needed. +1 QOTW -- \ “Are you pondering what I'm ponderi

Re: How to print all expressions that match a regular expression

2010-02-06 Thread Roy Smith
In article , "hzh...@gmail.com" wrote: > Hi, > > I am a fresh man with python. I know there is regular expressions in > Python. What I need is that given a particular regular expression, > output all the matches. For example, given ³[1|2|3]{2}² as the regular > expression, the program should o

How to print all expressions that match a regular expression

2010-02-06 Thread hzh...@gmail.com
Hi, I am a fresh man with python. I know there is regular expressions in Python. What I need is that given a particular regular expression, output all the matches. For example, given “[1|2|3]{2}” as the regular expression, the program should output all 9 matches, i.e., "11 12 13 21 22 23 31 32 33"