Re: Another Regexp Question

2010-07-06 Thread andrew cooke
http://bugs.python.org/issue9179 On Jul 5, 9:38 pm, MRAB wrote: > andrew cooke wrote: > > On Jul 5, 8:56 pm, MRAB wrote: > >> andrew cooke wrote: > >>> What am I missing this time? :o( > >> Nothing. It's a bug. :-( > > > Sweet :o) > > > Thanks - do you want me to raise an issue or will you? > >

Re: Another Regexp Question

2010-07-05 Thread MRAB
andrew cooke wrote: On Jul 5, 8:56 pm, MRAB wrote: andrew cooke wrote: What am I missing this time? :o( Nothing. It's a bug. :-( Sweet :o) Thanks - do you want me to raise an issue or will you? You found it. You can have the pleasure. -- http://mail.python.org/mailman/listinfo/python-lis

Re: Another Regexp Question

2010-07-05 Thread andrew cooke
On Jul 5, 8:56 pm, MRAB wrote: > andrew cooke wrote: > > What am I missing this time? :o( > Nothing. It's a bug. :-( Sweet :o) Thanks - do you want me to raise an issue or will you? Cheers, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Another Regexp Question

2010-07-05 Thread MRAB
andrew cooke wrote: As ever, I guess it's most likely I've misunderstood something, but in Python 2.6 lookback seems to actually be lookahead. All the following tests pass: from re import compile assert compile('(a)b(?<=(?(2)x|c))(c)').match('abc') assert not compile('(

Another Regexp Question

2010-07-05 Thread andrew cooke
As ever, I guess it's most likely I've misunderstood something, but in Python 2.6 lookback seems to actually be lookahead. All the following tests pass: from re import compile assert compile('(a)b(?<=(?(2)x|c))(c)').match('abc') assert not compile('(a)b(?<=(?(2)b|x))(c)'

Re: string parsing / regexp question

2007-11-28 Thread Ryan Krauss
On Nov 28, 2007 1:23 PM, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote: > > I need to parse the following string: > > > > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2 > > }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr

Re: string parsing / regexp question

2007-11-28 Thread Ryan Krauss
Interesting. Thanks Paul and Tim. This looks very promising. Ryan On Nov 28, 2007 1:23 PM, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote: > > I need to parse the following string: > > > > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left

Re: string parsing / regexp question

2007-11-28 Thread Tim Chase
Paul McGuire wrote: > On Nov 28, 1:23 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: >> As Tim Grove points out, ... > > s/Grove/Chase/ > > Sorry, Tim! No problem...it's not like there aren't enough Tim's on the list as it is. :) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: string parsing / regexp question

2007-11-28 Thread Paul McGuire
On Nov 28, 1:23 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > As Tim Grove points out, ... s/Grove/Chase/ Sorry, Tim! -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: string parsing / regexp question

2007-11-28 Thread Paul McGuire
On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote: > I need to parse the following string: > > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2 > }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F > }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_

Re: string parsing / regexp question

2007-11-28 Thread Tim Chase
> The trick is that there are extra curly braces inside the \pmatrix{ } > strings and I don't know how to write a regexp that would count the > number of open and close curly braces and make sure they match, so > that it can find the correct ending curly brace. This criterion is pretty much a deal

string parsing / regexp question

2007-11-28 Thread Ryan Krauss
I need to parse the following string: $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2 }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1 \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr }

Re: RegExp question

2006-04-11 Thread John Machin
Precise? The OP asked for "tokens". #>>> re.search(r"(and|or|xor)\s*#", "a = the_operand # gotcha!") #<_sre.SRE_Match object at 0x00AE6620> Try this: #>>> re.search(r"\b(and|or|xor)\s*#", "a = the_operand # should fail") #>>> re.search(r"\b(and|or|xor)\s*#", "and # OK") #<_sre.SRE_Match object a

Re: RegExp question

2006-04-11 Thread Ben C
On 2006-04-11, Michael McGarry <[EMAIL PROTECTED]> wrote: > Tim, > > for some reason that does not seem to do the trick. > > I am testing it with grep. (i.e., grep -e '(and|or|xor)\s*#' myfile) Try with grep -P, which means use perl-compatible regexes as opposed to POSIX ones. I only know for sure

Re: RegExp question

2006-04-11 Thread John Machin
(-: Sorry about Tim. He's not very imaginative. He presumed that because you asked on comp.lang.python that you would be testing it with Python. You should have either (a) asked your question on comp.toolswithfunnynames.grep or (b) not presumed that grep's re syntax is the same as Python's. :-) My

Re: RegExp question

2006-04-11 Thread Tim Chase
> I am testing it with grep. (i.e., grep -e '(and|or|xor)\s*#' myfile) Well, you asked for the python regexp...different environments use different regexp parsing engines. Your response is akin to saying "the example snippet of python code you gave me doesn't work in my Pascal program". For g

Re: RegExp question

2006-04-11 Thread Ben C
On 2006-04-11, Michael McGarry <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to form a regular expression to find a few different > tokens (and, or, xor) followed by some variable number of whitespace > (i.e., tabs and spaces) followed by a hash mark (i.e., #). What would > be the regular expre

Re: RegExp question

2006-04-11 Thread RunLevelZero
In my opinion you would be best to use a tool like Kiki. http://project5.freezope.org/kiki/index.html/# This will allow you to paste in the actual text you want to search and then play with different RE's and set flags with a simple mouse click so you can find just what you want. Rember what re.D

Re: RegExp question

2006-04-11 Thread Heiko Wundram
Am Dienstag 11 April 2006 21:16 schrieb Michael McGarry: > I am testing it with grep. (i.e., grep -e '(and|or|xor)\s*#' myfile) Test it with Python's re-module, then. \s for matching Whitespace is specific to Python (AFAIK). And as you've asked in a Python Newsgroup, you'll get Python-answers he

Re: RegExp question

2006-04-11 Thread Paul McGuire
"Michael McGarry" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I would like to form a regular expression to find a few different > tokens (and, or, xor) followed by some variable number of whitespace > (i.e., tabs and spaces) followed by a hash mark (i.e., #). What would >

Re: RegExp question

2006-04-11 Thread Michael McGarry
Tim, for some reason that does not seem to do the trick. I am testing it with grep. (i.e., grep -e '(and|or|xor)\s*#' myfile) Michael -- http://mail.python.org/mailman/listinfo/python-list

Re: RegExp question

2006-04-11 Thread Tim Chase
> I would like to form a regular expression to find a few > different tokens (and, or, xor) followed by some variable > number of whitespace (i.e., tabs and spaces) followed by > a hash mark (i.e., #). What would be the regular > expression for this? (and|or|xor)\s*# Unless "varible numb

RegExp question

2006-04-11 Thread Michael McGarry
Hi, I would like to form a regular expression to find a few different tokens (and, or, xor) followed by some variable number of whitespace (i.e., tabs and spaces) followed by a hash mark (i.e., #). What would be the regular expression for this? Thanks for any help, Michael -- http://mail.pytho

Re: Regexp question

2004-12-01 Thread Mitja
On Wed, 1 Dec 2004 07:48:24 -0600, Philippe C. Martin <[EMAIL PROTECTED]> wrote: I realize this is more a regexp question than a python question, but maybe one of the re object could help me: I have wish to know how to _no_ match: This is but an example of the data I handle: xx xx xx

Re: Regexp question

2004-12-01 Thread Miki Tebeka
Hello Philippe, > What I would rather do is. > > "get the data block that is _not_ between brackets or parenthesis i.e; 'xx > xx > xx xx xx xx xx' knowing that the intial string could be: See http://docs.python.org/lib/re-syntax.html and search for "negative lookahead" HTH. -- ---

Regexp question

2004-12-01 Thread Philippe C. Martin
I realize this is more a regexp question than a python question, but maybe one of the re object could help me: I have wish to know how to _no_ match: This is but an example of the data I handle: xx xx xx xx xx xx xx [yy yy yy yy yy yy yy] (zz zz zz zz) I currently can retrieve the three group