Newbie regular expression ?

2005-10-04 Thread len
I have the following statement and it works fine; list1 = glob.glob('*.dat') however I now have an additional requirement the the string must begin with any form of UNQ,Unq,unq,... as an example if I had the following four files in the directory: unq123abc.dat xy4223.dat myfile.dat

Re: Newbie regular expression ?

2005-10-04 Thread jepler
Here are two ideas that come to mind: files = glob.glob(UNQ*.dat) + glob.glob(Unq*.dat) + glob.glob(unq.dat) files = [f for f in glob.glob(*.dat) if f[:3] in (UNQ, Unq, unq)] Jeff pgp30Rue2EGi7.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie regular expression ?

2005-10-04 Thread Micah Elliott
On Oct 04, len wrote: I have the following statement and it works fine; list1 = glob.glob('*.dat') however I now have an additional requirement the the string must begin with any form of UNQ,Unq,unq,... as an example if I had the following four files in the directory:

Re: Newbie regular expression ?

2005-10-04 Thread Fredrik Lundh
len [EMAIL PROTECTED] wrote: I have the following statement and it works fine; list1 = glob.glob('*.dat') that's a glob pattern, not a regular expression. however I now have an additional requirement the the string must begin with any form of UNQ,Unq,unq,... list1 =

Re: Newbie regular expression ?

2005-10-04 Thread Micah Elliott
On Oct 04, Micah Elliott wrote: $ man 3 fnmatch Actually man 7 glob would be better (assuming you've got *nix). Also note that globs are not regular expressions. pydoc glob is another reference. -- Micah Elliott mde at micah dot elliott dot name --

Re: Newbie regular expression ?

2005-10-04 Thread Steve Holden
len wrote: I have the following statement and it works fine; list1 = glob.glob('*.dat') however I now have an additional requirement the the string must begin with any form of UNQ,Unq,unq,... as an example if I had the following four files in the directory: unq123abc.dat

Re: Newbie regular expression ?

2005-10-04 Thread len
Thanks everyone for your help. I took the option of f1.lower().startswith(unq). Len Sumnler -- http://mail.python.org/mailman/listinfo/python-list

Newbie regular expression and whitespace question

2005-09-22 Thread googleboy
Hi. I am trying to collapse an html table into a single line. Basically, anytime I seewith nothing but whitespace between them, I'd like to remove all the whitespace, including newlines. I've read the how-to and I have tried a bunch of things, but nothing seems to work for me: -- table =

Re: Newbie regular expression and whitespace question

2005-09-22 Thread Bruno Desthuilliers
googleboy a écrit : Hi. I am trying to collapse an html table into a single line. Basically, anytime I seewith nothing but whitespace between them, I'd like to remove all the whitespace, including newlines. I've read the how-to and I have tried a bunch of things, but nothing seems to

Re: Newbie regular expression and whitespace question

2005-09-22 Thread Paul McGuire
googleboy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi. I am trying to collapse an html table into a single line. Basically, anytime I seewith nothing but whitespace between them, I'd like to remove all the whitespace, including newlines. I've read the how-to and I have

Re: Newbie regular expression and whitespace question

2005-09-22 Thread Fredrik Lundh
Paul McGuire wrote: If you're absolutely stuck on using RE's, then others will have to step forward. Meanwhile, here's a pyparsing solution (get pyparsing at http://pyparsing.sourceforge.net): so, let's see. using ... from pyparsing import * import re data = ... table example from op ...

Re: Newbie regular expression and whitespace question

2005-09-22 Thread George Sakkis
googleboy [EMAIL PROTECTED] wrote: Hi. I am trying to collapse an html table into a single line. Basically, anytime I seewith nothing but whitespace between them, I'd like to remove all the whitespace, including newlines. I've read the how-to and I have tried a bunch of things, but

Re: Newbie regular expression and whitespace question

2005-09-22 Thread googleboy
Thanks for the great positive responses. I was close with what I was trying, I guess, but close only counts in horseshoes and um.. something else that close counts in. :-) googleboy -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie regular expression and whitespace question

2005-09-22 Thread Paul McGuire
Fredrik Lundh [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] snip - timing and sample code, comparing pyparsing (test3) with comparable regexp (test4) timeit -s import test test.test3() 100 loops, best of 3: 6.73 msec per loop timeit -s import test test.test4() 1 loops, best

Simple (newbie) regular expression question

2005-01-21 Thread André Roberge
Sorry for the simple question, but I find regular expressions rather intimidating. And I've never needed them before ... How would I go about to 'define' a regular expression that would identify strings like __alphanumerical__ as in __init__ (Just to spell things out, as I have seen underscores

Re: Simple (newbie) regular expression question

2005-01-21 Thread John Machin
André Roberge wrote: Sorry for the simple question, but I find regular expressions rather intimidating. And I've never needed them before ... How would I go about to 'define' a regular expression that would identify strings like __alphanumerical__ as in __init__ (Just to spell things

Re: Simple (newbie) regular expression question

2005-01-21 Thread André Roberge
John Machin wrote: André Roberge wrote: Sorry for the simple question, but I find regular expressions rather intimidating. And I've never needed them before ... How would I go about to 'define' a regular expression that would identify strings like __alphanumerical__ as in __init__ (Just to spell