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 variants but no

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

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 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

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. print

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

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

2010-02-06 Thread Roy Smith
In article ee2cfd35-3171-4ee7-ad3a-cf117e552...@r24g2000yqd.googlegroups.com, hzh...@gmail.com 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

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

2010-02-06 Thread Ben Finney
Roy Smith r...@panix.com writes: hzh...@gmail.com 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

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

2010-02-06 Thread hzh...@gmail.com
-cf117e552...@r24g2000yqd.googlegroups.com,  hzh...@gmail.com 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

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 Alf P. Steinbach
for a given program? This, in turn, is equivalent to the Halting Problem -- if you can solve one, you can solve the other. You might like to google on the Halting Problem before you spend too much time on this. Hm, well, text editors /regularly/ do repeated regular expression searches, producing

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

2010-02-06 Thread Steven D'Aprano
? This, in turn, is equivalent to the Halting Problem -- if you can solve one, you can solve the other. You might like to google on the Halting Problem before you spend too much time on this. Hm, well, text editors /regularly/ do repeated regular expression searches, producing match after match

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

2010-02-06 Thread MRAB
that is usable as valid input for a given program? This, in turn, is equivalent to the Halting Problem -- if you can solve one, you can solve the other. You might like to google on the Halting Problem before you spend too much time on this. Hm, well, text editors /regularly/ do repeated regular

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

2010-02-06 Thread Grant Edwards
On 2010-02-06, Roy Smith r...@panix.com 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

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

2010-02-06 Thread Alf P. Steinbach
for a given program? This, in turn, is equivalent to the Halting Problem -- if you can solve one, you can solve the other. You might like to google on the Halting Problem before you spend too much time on this. Hm, well, text editors /regularly/ do repeated regular expression searches, producing match

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. We

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

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

2010-02-06 Thread Nobody
] context-sensitive linear-bounded automaton[2] recursively-enumerable Turing machine However, any regular expression syntax which allows backreferences (including the POSIX specification) isn't actually regular in the formal sense (as it requires an infinite number of states

Re: Using dictionary key as a regular expression class

2010-01-23 Thread Chris Jones
On Sat, Jan 23, 2010 at 02:45:41AM EST, Terry Reedy wrote: On 1/22/2010 9:58 PM, Chris Jones wrote: Do you mean I should just read the file one character at a time? Whoops, my misdirection (you can .read(1), but this is s l o w. I meant to suggest processing it a char at a time.

Re: Using dictionary key as a regular expression class

2010-01-23 Thread Steve Holden
Chris Jones wrote: On Fri, Jan 22, 2010 at 05:07:13PM EST, Arnaud Delobelle wrote: [..] import codecs from collections import defaultdict tcounters = defaultdict(int) f = codecs.open('/home/gavron/git/screen/src/screen.c', 'r', utf-8) for c in f.read(): tcounters[c] += 1 for c,

Using dictionary key as a regular expression class

2010-01-22 Thread Chris Jones
I was writing a script that counts occurrences of characters in source code files: #!/usr/bin/python import codecs tcounters = {} f = codecs.open('/home/gavron/git/screen/src/screen.c', 'r', utf-8) for uline in f: lline = [] for char in uline[:-1]: lline += [char] counters = {} for i

Re: Using dictionary key as a regular expression class

2010-01-22 Thread Arnaud Delobelle
Chris Jones cjns1...@gmail.com writes: I was writing a script that counts occurrences of characters in source code files: #!/usr/bin/python import codecs tcounters = {} f = codecs.open('/home/gavron/git/screen/src/screen.c', 'r', utf-8) for uline in f: lline = [] for char in

Re: Using dictionary key as a regular expression class

2010-01-22 Thread Chris Jones
On Fri, Jan 22, 2010 at 05:07:13PM EST, Arnaud Delobelle wrote: [..] import codecs from collections import defaultdict tcounters = defaultdict(int) f = codecs.open('/home/gavron/git/screen/src/screen.c', 'r', utf-8) for c in f.read(): tcounters[c] += 1 for c, n in

Re: Using dictionary key as a regular expression class

2010-01-22 Thread Terry Reedy
On 1/22/2010 4:47 PM, Chris Jones wrote: I was writing a script that counts occurrences of characters in source code files: #!/usr/bin/python import codecs tcounters = {} f = codecs.open('/home/gavron/git/screen/src/screen.c', 'r', utf-8) for uline in f: lline = [] for char in

Re: Using dictionary key as a regular expression class

2010-01-22 Thread Chris Jones
On Fri, Jan 22, 2010 at 08:46:35PM EST, Terry Reedy wrote: On 1/22/2010 4:47 PM, Chris Jones wrote: I was writing a script that counts occurrences of characters in source code files: #!/usr/bin/python import codecs tcounters = {} f = codecs.open('/home/gavron/git/screen/src/screen.c',

Re: Using dictionary key as a regular expression class

2010-01-22 Thread Terry Reedy
On 1/22/2010 9:58 PM, Chris Jones wrote: On Fri, Jan 22, 2010 at 08:46:35PM EST, Terry Reedy wrote: Do you mean I should just read the file one character at a time? Whoops, my misdirection (you can .read(1), but this is s l o w. I meant to suggest processing it a char at a time. 1. If

OT: regular expression matching multiple occurrences of one group

2009-11-09 Thread pinkisntwell
How can I make a regular expression that will match every occurrence of a group and return each occurrence as a group match? For example, for a string -c-c-c-c-c, how can I make a regex which will return a group match for each occurrence of -c? -- http://mail.python.org/mailman/listinfo/python

Re: OT: regular expression matching multiple occurrences of one group

2009-11-09 Thread Diez B. Roggisch
pinkisntwell schrieb: How can I make a regular expression that will match every occurrence of a group and return each occurrence as a group match? For example, for a string -c-c-c-c-c, how can I make a regex which will return a group match for each occurrence of -c? Why is this flagged OT

Re: OT: regular expression matching multiple occurrences of one group

2009-11-09 Thread Jon Clements
On Nov 9, 1:53 pm, pinkisntwell pinkisntw...@gmail.com wrote: How can I make a regular expression that will match every occurrence of a group and return each occurrence as a group match? For example, for a string -c-c-c-c-c, how can I make a regex which will return a group match for each

Re: OT: regular expression matching multiple occurrences of one group

2009-11-09 Thread sln
On Mon, 9 Nov 2009 05:53:00 -0800 (PST), pinkisntwell pinkisntw...@gmail.com wrote: How can I make a regular expression that will match every occurrence of a group and return each occurrence as a group match? For example, for a string -c-c-c-c-c, how can I make a regex which will return a group

Re: OT: regular expression matching multiple occurrences of one group

2009-11-09 Thread J�rgen Exner
pinkisntwell pinkisntw...@gmail.com wrote: How can I make a regular expression that will match every occurrence of a group and return each occurrence as a group match? For example, for a string -c-c-c-c-c, how can I make a regex which will return a group match for each occurrence of -c? Where

Re: OT: regular expression matching multiple occurrences of one group

2009-11-09 Thread Gabriel Genellina
En Mon, 09 Nov 2009 12:59:53 -0300, Jon Clements jon...@googlemail.com escribió: On Nov 9, 1:53 pm, pinkisntwell pinkisntw...@gmail.com wrote: How can I make a regular expression that will match every occurrence of a group and return each occurrence as a group match? For example

Re: Please help with regular expression finding multiple floats

2009-10-26 Thread Jeremy
On Oct 24, 12:00 am, Edward Dolan byteco...@gmail.com wrote: No, you're not missing a thing. I am ;) Something was happening with the triple-quoted strings when I pasted them. Here is hopefully, the correct code.http://codepad.org/OIazr9lA The output is shown on that page as well. Sorry

Re: Please help with regular expression finding multiple floats

2009-10-24 Thread Edward Dolan
No, you're not missing a thing. I am ;) Something was happening with the triple-quoted strings when I pasted them. Here is hopefully, the correct code. http://codepad.org/OIazr9lA The output is shown on that page as well. Sorry for the line noise folks. One of these days I'm going to learn gnus.

Re: Please help with regular expression finding multiple floats

2009-10-23 Thread Edward Dolan
are hella fun to play with. You have to ask yourself, Do I really _need_ to use a regular expression here? -- http://mail.python.org/mailman/listinfo/python-list

Re: Please help with regular expression finding multiple floats

2009-10-23 Thread Edward Dolan
I can see why this line could wrap 1.E-08 1.58024E-06 0.0048 1.E-08 1.58024E-06 0.0048 But this one? 1.E-07 2.98403E-05 0.0018 anyway, here is the code - http://codepad.org/Z7eWBusl -- http://mail.python.org/mailman/listinfo/python-list

Re: Please help with regular expression finding multiple floats

2009-10-23 Thread Jeremy
will probably fail. At that point, you have to fiddle with the re to get it back on course. Don't get me wrong, regular expressions are hella fun to play with. You have to ask yourself, Do I really _need_ to use a regular expression here? In this simplified example I don't really need regular

Please help with regular expression finding multiple floats

2009-10-22 Thread Jeremy
', '0.0017') ('1.93417E-04', '0.0012')] as a result. I have the regular expression pattern fp1 = '([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)\s+' which can find a floating point number followed by some space. I can find three floats with found = re.findall('%s%s%s' %fp1, text) My question is, how can I use

Re: Please help with regular expression finding multiple floats

2009-10-22 Thread Rhodri James
to capture the two or three floating point numbers in each line and store them in a tuple. I want to find all such tuples such that I have [('1.E-08', '1.58024E-06', '0.0048'), [snip] ('5.E+00', '2.42717E-05', '0.0017') ('1.93417E-04', '0.0012')] as a result. I have the regular

Re: Please help with regular expression finding multiple floats

2009-10-22 Thread Cousin Stanley
I have text that looks like the following (but all in one string with '\n' separating the lines): I want to capture the two or three floating point numbers in each line and store them in a tuple. I have the regular expression pattern Jeremy For a non-regular

Re: Regular expression to structure HTML

2009-10-05 Thread Stefan Behnel
504cr...@gmail.com wrote: No -- sorry -- I don't want to use BeautifulSoup (though I have for other projects). Humor me, please -- I'd really like to see if this can be done with just regular expressions. I think the reason why people are giving funny comments here is that you failed to

Re: Regular expression to structure HTML

2009-10-04 Thread Nobody
On Thu, 01 Oct 2009 22:10:55 -0700, 504cr...@gmail.com wrote: I'm kind of new to regular expressions The most important thing to learn about regular expressions is to learn what they can do, what they can't do, and what they can do in theory but can't do in practice (usually because of

Re: Regular expression to structure HTML

2009-10-03 Thread 504cr...@gmail.com
On Oct 2, 11:14 pm, greg g...@cosc.canterbury.ac.nz wrote: Brian D wrote: This isn't merely a question of knowing when to use the right tool. It's a question about how to become a better developer using regular expressions. It could be said that if you want to learn how to use a hammer,

Re: Regular expression to structure HTML

2009-10-02 Thread Bruno Desthuilliers
504cr...@gmail.com a écrit : I'm kind of new to regular expressions, and I've spent hours trying to finesse a regular expression to build a substitution. What I'd like to do is extract data elements from HTML and structure them so that they can more readily be imported into a database

Re: Regular expression to structure HTML

2009-10-02 Thread Paul McGuire
On Oct 2, 12:10 am, 504cr...@gmail.com 504cr...@gmail.com wrote: I'm kind of new to regular expressions, and I've spent hours trying to finesse a regular expression to build a substitution. What I'd like to do is extract data elements from HTML and structure them so that they can more readily

Re: Regular expression to structure HTML

2009-10-02 Thread Stefan Behnel
Paul McGuire wrote: On Oct 2, 12:10 am, 504cr...@gmail.com 504cr...@gmail.com wrote: I'm kind of new to regular expressions, and I've spent hours trying to finesse a regular expression to build a substitution. What I'd like to do is extract data elements from HTML and structure them so

Re: Regular expression to structure HTML

2009-10-02 Thread John
On Oct 2, 1:10 am, 504cr...@gmail.com 504cr...@gmail.com wrote: I'm kind of new to regular expressions, and I've spent hours trying to finesse a regular expression to build a substitution. What I'd like to do is extract data elements from HTML and structure them so that they can more readily

Re: Regular expression to structure HTML

2009-10-02 Thread Brian D
the regular expression fails. The structure of the page I'm scraping is uniform in the production of tags -- it's an old ASP page that pulls data from a database. What's different in the first tr row is the appearance of a comma, a # pound symbol, and a number (, Inc #4). I'm making the assumption that's

Re: Regular expression to structure HTML

2009-10-02 Thread Brian D
, and I've spent hours trying to finesse a regular expression to build a substitution. What I'd like to do is extract data elements from HTML and structure them so that they can more readily be imported into a database. No -- sorry -- I don't want to use BeautifulSoup (though I have for other

Re: Regular expression to structure HTML

2009-10-02 Thread greg
Brian D wrote: This isn't merely a question of knowing when to use the right tool. It's a question about how to become a better developer using regular expressions. It could be said that if you want to learn how to use a hammer, it's better to practise on nails rather than screws. -- Greg --

Regular expression to structure HTML

2009-10-01 Thread 504cr...@gmail.com
I'm kind of new to regular expressions, and I've spent hours trying to finesse a regular expression to build a substitution. What I'd like to do is extract data elements from HTML and structure them so that they can more readily be imported into a database. No -- sorry -- I don't want to use

Regular Expression problem

2009-09-08 Thread ���m�ۤv...@����
I have the following source code import re d = 'RTCB\r\nsignature:\xf1\x11

Re: Regular Expression problem

2009-09-08 Thread Vlastimil Brom
2009/9/8 找尋自己的一片天 command@alexbbs.twbbs.org: I have the following source code import re d = 'RTCB\r\nsignature:\xf1\x11

Re: Regular Expression problem

2009-09-08 Thread Steven D'Aprano
On Tue, 08 Sep 2009 09:21:35 +, §äŽmŠÛ€vªº...@€ù€Ñ wrote: I have the following source code import re d = 'RTCB\r\nsignature:\xf1\x11 \xde\x10\xfe\x0f\x9c\x10\xf6\xc9_\x10\xf3\xeb\x10\xf2Zt\x10\xef\xd2\x91

regular expression

2009-08-20 Thread Pierre
Hello, I would like to change the string (1 and (2 or 3)) by (x[1] (x [2] || x[3])) using regular expression... Anyone can help me ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expression

2009-08-20 Thread Steven D'Aprano
On Thu, 20 Aug 2009 00:18:23 -0700, Pierre wrote: Hello, I would like to change the string (1 and (2 or 3)) by (x[1] (x [2] || x[3])) using regular expression... Anyone can help me ? Do you mean you want to change the string into (x[1] (x[2] || x[3])) ? Does it have to be using

Re: regular expression

2009-08-20 Thread Peter Otten
Pierre wrote: I would like to change the string (1 and (2 or 3)) by (x[1] (x [2] || x[3])) using regular expression... Anyone can help me ? re.compile(r(\d+)).sub(rx[\1], (1 and (2 or 3))) '(x[1] and (x[2] or x[3]))' re.compile(and|or).sub(lambda m, d={and:, or:||}: d[m.group()], _) '(x

Re: Regular expression solution

2009-07-28 Thread Nobody
On Tue, 28 Jul 2009 16:12:19 -0700, nickname wrote: I'm a newbie with python. I am looking to write a regex program which can take in a piece of text and remove some parts of it and supply the remaining parts back. The input can be something like: scriptdocument.write(h +e+ ll+

Re: Regular expression solution

2009-07-28 Thread tiefeng wu
2009/7/29 Nobody nob...@nowhere.com: The output should be something like scriptdocument.write(hello my name is  21c;)/script import re r = re.compile(r'\s*\+\s*') s = r'''scriptdocument.write(h +e+ ll+ o+ m +y+ n+ame+ is  +21c;)/script''' r.sub('', s) Nobody's solution is good.

Re: Regular expression solution

2009-07-28 Thread Brian
On Tue, Jul 28, 2009 at 9:11 PM, tiefeng wu iceberg...@gmail.com wrote: 2009/7/29 Nobody nob...@nowhere.com: The output should be something like scriptdocument.write(hello my name is 21c;)/script import re r = re.compile(r'\s*\+\s*') s = r'''scriptdocument.write(h +e+ ll+ o+

extract c/cpp include file with regular expression

2009-07-23 Thread tiefeng wu
Hi all! I need to parse c/cpp source files, one requirement is to extract included header file name. here is my solution: p = re.compile(r'#\s*include\s+(?:()|())(.*)(?(1))(?(2))') m = re.search(p, '#include header.h') m.group(3) 'header.h' m = re.search(p, '#include header.h') m.group(3)

Re: extract c/cpp include file with regular expression

2009-07-23 Thread Philip Semanchuk
On Jul 23, 2009, at 11:46 AM, tiefeng wu wrote: Hi all! I need to parse c/cpp source files, one requirement is to extract included header file name. here is my solution: p = re.compile(r'#\s*include\s+(?:()|())(.*)(?(1))(?(2))') m = re.search(p, '#include header.h') m.group(3) 'header.h' m

Re: extract c/cpp include file with regular expression

2009-07-23 Thread MRAB
tiefeng wu wrote: Hi all! I need to parse c/cpp source files, one requirement is to extract included header file name. here is my solution: p = re.compile(r'#\s*include\s+(?:()|())(.*)(?(1))(?(2))') m = re.search(p, '#include header.h') m.group(3) 'header.h' m = re.search(p, '#include

Re: extract c/cpp include file with regular expression

2009-07-23 Thread tiefeng wu
MRAB wrote: I'd probably do: p = re.compile(r'#\s*include\s+(?:([^]*)|([^]*))') m = p.search('#include header.h') m.group(1) or m.group(2) 'header.h' yes, it's easier to understand. thanks, MRAB! I always make things complicated :P tiefeng wu 2009-07-23 --

Re: extract c/cpp include file with regular expression

2009-07-23 Thread tiefeng wu
2009/7/24 Philip Semanchuk phi...@semanchuk.com: I know this will sound like a sarcastic comment, but it is sincere: my suggestion is that if you want to parse C/C++ (or Python, or Perl, or Fortran, etc.), use a real parser, not regexes unless you're willing to sacrifice some accuracy. Sooner

Re: extract c/cpp include file with regular expression

2009-07-23 Thread Philip Semanchuk
On Jul 23, 2009, at 12:36 PM, tiefeng wu wrote: 2009/7/24 Philip Semanchuk phi...@semanchuk.com: I know this will sound like a sarcastic comment, but it is sincere: my suggestion is that if you want to parse C/C++ (or Python, or Perl, or Fortran, etc.), use a real parser, not regexes

Re: extract c/cpp include file with regular expression

2009-07-23 Thread Nick Craig-Wood
tiefeng wu iceberg...@gmail.com wrote: I need to parse c/cpp source files, one requirement is to extract included header file name. If you are serious about parsing C code then you'll want to investigate gcc-xml http://www.gccxml.org/HTML/Index.html This runs the gcc frontend over the code

Regular expression

2009-07-21 Thread Peter Fodrek
Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') with code def readline(self): self.line = self.file_in.readline().rstrip() if (len(self.line)) : return True

Re: Regular expression

2009-07-21 Thread MRAB
Peter Fodrek wrote: Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') [snip] It handles file correctly with two exceptions 1) omits ',' in the a output 2) omits minus sign

Re: Regular expression

2009-07-21 Thread Rhodri James
On Tue, 21 Jul 2009 14:30:47 +0100, Peter Fodrek peter.fod...@stuba.sk wrote: Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') Always use raw strings (r...) when you're

Re: Regular expression

2009-07-21 Thread Peter Fodrek
21.7.2009 v 16:50, MRAB: Peter Fodrek wrote: Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d +|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') [snip] It handles file correctly with two exceptions 1) omits

Re: Regular expression

2009-07-21 Thread Jean-Michel Pichavant
Rhodri James wrote: On Tue, 21 Jul 2009 14:30:47 +0100, Peter Fodrek peter.fod...@stuba.sk wrote: Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') Also, whoever wrote

Re: Regular expression

2009-07-21 Thread Rhodri James
need the full power of a regular expression here. split() would do the trick: words = self.line.split() will return what you want for that example. It will produce different (but more consistent) results than the regular expression for other lines, though: for example, MA 52.8806 , 18.0914

[issue6465] email.feedparser regular expression bug (NLCRE_crack)

2009-07-17 Thread Terry J. Reedy
Terry J. Reedy tjre...@udel.edu added the comment: I believe both 2.4 and 3.0 are no longer maintained. 2.5 only gets security fixes. On the otherhand, fix should go into 3.2 ;-). -- nosy: +tjreedy versions: +Python 3.2 -Python 2.4, Python 2.5, Python 3.0

[issue6465] email.feedparser regular expression bug (NLCRE_crack)

2009-07-12 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Can you include your unit test in your patch rather than as a separate script? Existing unit tests are in Lib/test. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org

[issue6465] email.feedparser regular expression bug (NLCRE_crack)

2009-07-12 Thread jkg
jkg pyt...@slashbot.com added the comment: Combined patch as requested by pitrou. (Sorry. This is my first submission.) -- Added file: http://bugs.python.org/file14486/nlcre_full.patch ___ Python tracker rep...@bugs.python.org

[issue6465] email.feedparser regular expression bug (NLCRE_crack)

2009-07-12 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Sorry for giving you a slightly wrong indication. The email tests are called from Lib/test/test_email.py, but it redirects to Lib/email/test/*. In any case, there's no point in creating a separate test script for such a detail, you should add your

[issue6465] email.feedparser regular expression bug (NLCRE_crack)

2009-07-11 Thread jkg
to follow. -- components: Library (Lib) files: test_nlcre.py messages: 90433 nosy: barry, jkg, tony_nelson severity: normal status: open title: email.feedparser regular expression bug (NLCRE_crack) type: behavior versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1

[issue6465] email.feedparser regular expression bug (NLCRE_crack)

2009-07-11 Thread jkg
jkg pyt...@slashbot.com added the comment: Patch. -- keywords: +patch Added file: http://bugs.python.org/file14485/nlcre.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6465 ___

Help to find a regular expression to parse po file

2009-07-06 Thread gialloporpora
Hi all, I would like to extract string from a PO file. To do this I have created a little python function to parse po file and extract string: import re regex=re.compile(msgid (.*)\\nmsgstr (.*)\\n\\n) m=r.findall(s) where s is a po file like this: msgctxt write ubiquity commands.description

Re: Help to find a regular expression to parse po file

2009-07-06 Thread Hallvard B Furuseth
gialloporpora writes: I would like to extract string from a PO file. To do this I have created a little python function to parse po file and extract string: import re regex=re.compile(msgid (.*)\\nmsgstr (.*)\\n\\n) m=r.findall(s) I don't know the syntax of a po file, but this works for the

Re: Help to find a regular expression to parse po file

2009-07-06 Thread MRAB
gialloporpora wrote: Hi all, I would like to extract string from a PO file. To do this I have created a little python function to parse po file and extract string: import re regex=re.compile(msgid (.*)\\nmsgstr (.*)\\n\\n) m=r.findall(s) where s is a po file like this: msgctxt write

Re: Help to find a regular expression to parse po file

2009-07-06 Thread gialloporpora
Risposta al messaggio di Hallvard B Furuseth : I don't know the syntax of a po file, but this works for the snippet you posted: arg_re = r'[^\\\]*(?:\\.[^\\\]*)*' arg_re = '%s(?:\s+%s)*' % (arg_re, arg_re) find_re = re.compile( r'^msgid\s+(' + arg_re + ')\s*\nmsgstr\s+(' + arg_re +

Re: Help to find a regular expression to parse po file

2009-07-06 Thread gialloporpora
Risposta al messaggio di MRAB : gialloporpora wrote: Hi all, I would like to extract string from a PO file. To do this I have created a little python function to parse po file and extract string: import re regex=re.compile(msgid (.*)\\nmsgstr (.*)\\n\\n) m=r.findall(s) where s is a po file

Regular Expression Non Capturing Grouping Does Not Work.

2009-06-27 Thread Virtual Buddha
Hello all, I am having some difficulties with the non-capturing grouping in python regular expression module. Even the code from the online documentation (http://docs.python.org/ howto/regex.html#non-capturing-and-named-groups) does not seem to work. As per the docs given in the link above

Re: Regular Expression Non Capturing Grouping Does Not Work.

2009-06-27 Thread Miles Kaufmann
On Jun 27, 2009, at 3:28 AM, Virtual Buddha wrote: Hello all, I am having some difficulties with the non-capturing grouping in python regular expression module. Even the code from the online documentation (http://docs.python.org/ howto/regex.html#non-capturing-and-named-groups) does not seem

Re: Regular Expression Non Capturing Grouping Does Not Work.

2009-06-27 Thread Peter Otten
Virtual Buddha wrote: Hello all, I am having some difficulties with the non-capturing grouping in python regular expression module. Even the code from the online documentation (http://docs.python.org/ howto/regex.html#non-capturing-and-named-groups) does not seem to work. As per

Re: Regular Expression Non Capturing Grouping Does Not Work.

2009-06-27 Thread Virtual Buddha
group != groups match.group() or match.group(0) gives you a special group that comprises the whole match. Regular capturing groups start at index 1, and only those are returned by match.groups(): re.match((?:[abc])+, abc).group() # one group 'abc' re.match((?:[abc])+, abc).groups() #

Re: Need help in Python regular expression

2009-06-12 Thread Vlastimil Brom
2009/6/12 meryl silverburgh.me...@gmail.com: On Jun 11, 9:41 pm, Mark Tolonen metolone+gm...@gmail.com wrote: meryl silverburgh.me...@gmail.com wrote in message I have this regular expression ... I try adding .* at the end , but it ends up just matching the second one. If there can

Re: Need help in Python regular expression

2009-06-12 Thread Jean-Michel Pichavant
To the OP, I suggest if you haven't yet Kodos, to get it here http://kodos.sourceforge.net/. It's a python regexp debugger, a lifetime saver. Jean-Michel John S wrote: On Jun 11, 10:30 pm, meryl silverburgh.me...@gmail.com wrote: Hi, I have this regular expression blockRE = re.compile

Re: Need help in Python regular expression

2009-06-12 Thread Rhodri James
On Fri, 12 Jun 2009 06:20:24 +0100, meryl silverburgh.me...@gmail.com wrote: On Jun 11, 9:41 pm, Mark Tolonen metolone+gm...@gmail.com wrote: meryl silverburgh.me...@gmail.com wrote in message Hi, I have this regular expression blockRE = re.compile(.*RenderBlock {\w+}) it works if my

Need help in Python regular expression

2009-06-11 Thread meryl
Hi, I have this regular expression blockRE = re.compile(.*RenderBlock {\w+}) it works if my source is RenderBlock {CENTER}. But I want it to work with 1. RenderTable {TABLE} So i change the regexp to re.compile(.*Render[Block|Table] {\w+}), but that breaks everything 2. RenderBlock (CENTER

Re: Need help in Python regular expression

2009-06-11 Thread Mark Tolonen
meryl silverburgh.me...@gmail.com wrote in message news:2d4d8624-043b-4f5f-ae2d-bf73bca3d...@p6g2000pre.googlegroups.com... Hi, I have this regular expression blockRE = re.compile(.*RenderBlock {\w+}) it works if my source is RenderBlock {CENTER}. But I want it to work with 1. RenderTable

Re: Need help in Python regular expression

2009-06-11 Thread John S
On Jun 11, 10:30 pm, meryl silverburgh.me...@gmail.com wrote: Hi, I have this regular expression blockRE = re.compile(.*RenderBlock {\w+}) it works if my source is RenderBlock {CENTER}. But I want it to work with 1. RenderTable {TABLE} So i change the regexp to re.compile(.*Render[Block

Re: Need help in Python regular expression

2009-06-11 Thread meryl
On Jun 11, 9:41 pm, Mark Tolonen metolone+gm...@gmail.com wrote: meryl silverburgh.me...@gmail.com wrote in message news:2d4d8624-043b-4f5f-ae2d-bf73bca3d...@p6g2000pre.googlegroups.com... Hi, I have this regular expression blockRE = re.compile(.*RenderBlock {\w+}) it works if my

regular expression for getting content between parentheses

2009-05-07 Thread Rajanikanth Jammalamadaka
Hi I have a text file as follows: testName = ( someParam = value1 anotherParam = (value2, value3) ) how do I write a regular expression to get all the contents of the file which are between the first and last parentheses. In this case, I want: someParam = value1 anotherParam = (value2

Re: regular expression for getting content between parentheses

2009-05-07 Thread Emile van Sebille
On 5/7/2009 4:51 PM Rajanikanth Jammalamadaka said... Hi I have a text file as follows: testName = ( someParam = value1 anotherParam = (value2, value3) ) how do I write a regular expression to get all the contents of the file which are between the first and last parentheses. In this case

Re: regular expression for getting content between parentheses

2009-05-07 Thread Rhodri James
On Fri, 08 May 2009 00:51:14 +0100, Rajanikanth Jammalamadaka rajanika...@gmail.com wrote: Hi I have a text file as follows: testName = ( someParam = value1 anotherParam = (value2, value3) ) how do I write a regular expression to get all the contents of the file which are between

Re: regular expression for getting content between parentheses

2009-05-07 Thread Rajanikanth Jammalamadaka
+0100, Rajanikanth Jammalamadaka rajanika...@gmail.com wrote: Hi I have a text file as follows: testName = (  someParam = value1  anotherParam = (value2, value3) ) how do I write a regular expression to get all the contents of the file which are between the first and last parentheses

Re: regular expression, unicode

2009-04-30 Thread Simon Strobl
Thanks for your hints. Usually, all my files are utf-8. Obviously, I somehow managed to inadvertently switch the encoding when creating this specific file. I have no idea how this could happen. Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Using ascii numbers in regular expression

2009-04-30 Thread Lie Ryan
MRAB wrote: You're almost there: re.subn('\x61','b','') or better yet: re.subn(r'\x61','b','') Wouldn't that becomes a literal \x61 instead of a as it is inside raw string? -- http://mail.python.org/mailman/listinfo/python-list

<    4   5   6   7   8   9   10   11   12   13   >