Re: Help with Regular Expression

2015-05-19 Thread Tim Chase
On 2015-05-19 06:42, massi_...@msn.com wrote: > I succesfully wrote a regex in python in order to substitute all > the occurences in the form $"somechars" with another string. Here > it is: > > re.sub(ur"""(?u)(\$\"[^\"\\]*(?:\\.[^\"\\]*)*\")""", newstring, > string) The expression is a little mo

Help with Regular Expression

2015-05-19 Thread massi_srb
Hi everyone, I succesfully wrote a regex in python in order to substitute all the occurences in the form $"somechars" with another string. Here it is: re.sub(ur"""(?u)(\$\"[^\"\\]*(?:\\.[^\"\\]*)*\")""", newstring, string) Now I would need to exclude from the match all the string in the form $"

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 : (instan

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

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

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

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 desc

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

Re: Help with regular expression in python

2011-08-19 Thread jmfauth
On 19 août, 19:33, Matt Funk 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 point i will go

Re: Help with regular expression in python

2011-08-19 Thread Matt Funk
On Friday, August 19, 2011, Alain Ketterlin wrote: > Matt Funk 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 > > gett

Re: Help with regular expression in python

2011-08-19 Thread Alain Ketterlin
Matt Funk 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 greatly annoys me

Re: Help with regular expression in python

2011-08-19 Thread jmfauth
On 19 août, 17:20, Matt Funk 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 but more becaus

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

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 F

Re: Help with regular expression in python

2011-08-18 Thread Josh Benner
On Thu, Aug 18, 2011 at 4:03 PM, Matt Funk 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 =\ >r'(([-+]?

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}(.+)' instance_linetype_

Re: Help with regular expression in python

2011-08-18 Thread Vlastimil Brom
2011/8/18 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

Re: Help with regular expression in python

2011-08-18 Thread John Gordon
In Matt Funk 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.compile(instance_linetype_pattern_str) Does your regexp account for the s

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 poin

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 1.91

Re: Please help with regular expression finding multiple floats

2009-10-26 Thread Jeremy
On Oct 24, 12:00 am, Edward Dolan 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 for the line no

Re: Please help with regular expression finding multiple floats

2009-10-23 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 Jeremy
On Oct 23, 3:48 am, Edward Dolan wrote: > On Oct 22, 3:26 pm, Jeremy wrote: > > > My question is, how can I use regular expressions to find two OR three > > or even an arbitrary number of floats without repeating %s?  Is this > > possible? > > > Thanks, > > Jeremy > > Any time you have tabular da

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 Edward Dolan
On Oct 22, 3:26 pm, Jeremy wrote: > My question is, how can I use regular expressions to find two OR three > or even an arbitrary number of floats without repeating %s?  Is this > possible? > > Thanks, > Jeremy Any time you have tabular data such as your example, split() is generally the first ch

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

Re: Please help with regular expression finding multiple floats

2009-10-22 Thread Rhodri James
On Thu, 22 Oct 2009 23:26:01 +0100, Jeremy wrote: I have text that looks like the following (but all in one string with '\n' separating the lines): 1.E-08 1.58024E-06 0.0048 [snip] 5.E+00 2.42717E-05 0.0017 total 1.93417E-04 0.0012 I want to capture the two or

Please help with regular expression finding multiple floats

2009-10-22 Thread Jeremy
I have text that looks like the following (but all in one string with '\n' separating the lines): 1.E-08 1.58024E-06 0.0048 1.E-07 2.98403E-05 0.0018 1.E-06 8.85470E-06 0.0026 1.E-05 6.08120E-06 0.0032 1.E-03 1.61817E-05 0.0022 1.E+00 8.3

Help with regular expression patterns

2008-11-28 Thread Michel Perez
Hi: i'm so newbie in python that i don't get the right idea about regular expressions. This is what i want to do: Extract using python some information and them replace this expresion for others, i use as a base the wikitext and this is what i do: paragraphs = """ = Test '''wikitest'''= [[Image

Re: Looking for help with Regular Expression

2006-05-24 Thread Roger Miller
Seem to be a lot of regular expression questions lately. There is a neat little RE demonstrator buried down in Python24/Tools/Scripts/redemo.py, which makes it easy to experiment with regular expressions and immediately see the effect of changes. It would be helpful if it were mentioned in the RE d

Re: Looking for help with Regular Expression

2006-05-23 Thread lao_mage
'''\[(.*?)\]''' ?-> when this char after(*, +, ?, {n}, {n,}, {n,m}), the match pattern is not greedy e.g.1 String: 512.16[3][b]] Pattern:'''\[(.*)\]''' This will match "[3][b]]" e.g.2 String: 512.16[3][b]] Pattern:'''\[(.*)?\]''' This will match "[3]" and "[b]" -- http://mail.python.org/mailman

Re: Looking for help with Regular Expression

2006-05-23 Thread James Stroud
ProvoWallis wrote: > Hi, > > I'm looking for a little advice about regular expressions. I want to > capture a string of text that falls between an opening squre bracket > and a closing square bracket (e.g., "[" and "]") but I've run into a > small problem. > > I've been using this: '''\[(.*?)\]''

Looking for help with Regular Expression

2006-05-23 Thread ProvoWallis
Hi, I'm looking for a little advice about regular expressions. I want to capture a string of text that falls between an opening squre bracket and a closing square bracket (e.g., "[" and "]") but I've run into a small problem. I've been using this: '''\[(.*?)\]''' as my pattern. I was expecting th