Re: Help with regular expression in python

2011-08-22 Thread Vlastimil Brom
Sorry, if I missed some further specification in the earlier thread or if the following is oversimplification of the original problem (using 3 numbers instead of 32), would something like the following work for your data? import re data = 2.201000e+01 2.15e+01 2.199000e+01 : (instance: 0)

Re: Help with regular expression in python

2011-08-19 Thread Matt Funk
Hi Josh, thanks for the reply. I am no expert so please bear with me: I thought that the {32} was supposed to match the previous expression 32 times? So how can i have all matches accessible to me? matt On Thursday, August 18, 2011, Josh Benner wrote: On Thu, Aug 18, 2011 at 4:03 PM, Matt

Re: Help with regular expression in python

2011-08-19 Thread Jason Friedman
Hi Josh, thanks for the reply. I am no expert so please bear with me: I thought that the {32} was supposed to match the previous expression 32 times? So how can i have all matches accessible to me? $ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type help,

Re: Help with regular expression in python

2011-08-19 Thread Matt Funk
Hi, thanks for the suggestion. I guess i had found another way around the problem as well. But i really wanted to match the line exactly and i wanted to know why it doesn't work. That is less for the purpose of getting the thing to work but more because it greatly annoys me off that i can't figure

Re: Help with regular expression in python

2011-08-19 Thread jmfauth
On 19 août, 17:20, Matt Funk matze...@gmail.com wrote: Hi, thanks for the suggestion. I guess i had found another way around the problem as well. But i really wanted to match the line exactly and i wanted to know why it doesn't work. That is less for the purpose of getting the thing to work

Re: Help with regular expression in python

2011-08-19 Thread Alain Ketterlin
Matt Funk matze...@gmail.com writes: thanks for the suggestion. I guess i had found another way around the problem as well. But i really wanted to match the line exactly and i wanted to know why it doesn't work. That is less for the purpose of getting the thing to work but more because it

Re: Help with regular expression in python

2011-08-19 Thread Matt Funk
On Friday, August 19, 2011, Alain Ketterlin wrote: Matt Funk matze...@gmail.com writes: thanks for the suggestion. I guess i had found another way around the problem as well. But i really wanted to match the line exactly and i wanted to know why it doesn't work. That is less for the purpose

Re: Help with regular expression in python

2011-08-19 Thread jmfauth
On 19 août, 19:33, Matt Funk matze...@gmail.com wrote: The results obtained are: results: [(' 2.199000e+01', ' : (instance: 0)\t:\tsome description')] so this matches the last number plus the string at the end of the line, but no retaining the previous numbers. Anyway, i think at this

Re: Help with regular expression in python

2011-08-19 Thread ru...@yahoo.com
On 08/19/2011 11:33 AM, Matt Funk wrote: On Friday, August 19, 2011, Alain Ketterlin wrote: Matt Funk matze...@gmail.com writes: thanks for the suggestion. I guess i had found another way around the problem as well. But i really wanted to match the line exactly and i wanted to know why it

Re: Help with regular expression in python

2011-08-19 Thread Carl Banks
On Friday, August 19, 2011 10:33:49 AM UTC-7, Matt Funk wrote: number = r\d\.\d+e\+\d+ numbersequence = r%s( %s){31}(.+) % (number,number) instance_linetype_pattern = re.compile(numbersequence) The results obtained are: results: [(' 2.199000e+01', ' : (instance: 0)\t:\tsome description')]

Re: Help with regular expression in python

2011-08-19 Thread MRAB
On 19/08/2011 20:55, ru...@yahoo.com wrote: On 08/19/2011 11:33 AM, Matt Funk wrote: On Friday, August 19, 2011, Alain Ketterlin wrote: Matt Funkmatze...@gmail.com writes: thanks for the suggestion. I guess i had found another way around the problem as well. But i really wanted to match the

Re: Help with regular expression in python

2011-08-19 Thread Matt Funk
On Friday, August 19, 2011, jmfauth wrote: On 19 août, 19:33, Matt Funk matze...@gmail.com wrote: The results obtained are: results: [(' 2.199000e+01', ' : (instance: 0)\t:\tsome description')] so this matches the last number plus the string at the end of the line, but no retaining the

Re: Help with regular expression in python

2011-08-19 Thread Matt Funk
On Friday, August 19, 2011, Carl Banks wrote: On Friday, August 19, 2011 10:33:49 AM UTC-7, Matt Funk wrote: number = r\d\.\d+e\+\d+ numbersequence = r%s( %s){31}(.+) % (number,number) instance_linetype_pattern = re.compile(numbersequence) The results obtained are: results: [('

Help with regular expression in python

2011-08-18 Thread Matt Funk
Hi, i am sorry if this doesn't quite match the subject of the list. If someone takes offense please point me to where this question should go. Anyway, i have a problem using regular expressions. I would like to match the line: 1.002000e+01 2.037000e+01 2.128000e+01 1.908000e+01 1.871000e+01

Re: Help with regular expression in python

2011-08-18 Thread Martin Komoň
You don't seem to account for the whitespace between the floats. Try '([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?\s+){32}' (just added \s+). Martin On 8/18/2011 9:49 PM, Matt Funk wrote: Hi, i am sorry if this doesn't quite match the subject of the list. If someone takes offense please point

Re: Help with regular expression in python

2011-08-18 Thread John Gordon
In mailman.191.1313697016.27778.python-l...@python.org Matt Funk matze...@gmail.com writes: 1.002000e+01 2.037000e+01 2.128000e+01 1.908000e+01 1.871000e+01 1.914000e+01 instance_linetype_pattern_str = '([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?) {32}' instance_linetype_pattern =

Re: Help with regular expression in python

2011-08-18 Thread Vlastimil Brom
2011/8/18 Matt Funk matze...@gmail.com: Hi, i am sorry if this doesn't quite match the subject of the list. If someone takes offense please point me to where this question should go. Anyway, i have a problem using regular expressions. I would like to match the line: 1.002000e+01 2.037000e+01

Re: Help with regular expression in python

2011-08-18 Thread Matt Funk
Hi guys, thanks for the suggestions. I had tried the white space before as well (to no avail). So here is the expression i am using (based on suggestions), but still no success: instance_linetype_pattern_str =\ r'(([-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+))?\s+){32}(.+)'

Re: Help with regular expression in python

2011-08-18 Thread Josh Benner
On Thu, Aug 18, 2011 at 4:03 PM, Matt Funk matze...@gmail.com wrote: Hi guys, thanks for the suggestions. I had tried the white space before as well (to no avail). So here is the expression i am using (based on suggestions), but still no success: instance_linetype_pattern_str =\