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

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