Newbie regular expression ?

Steve Holden steve at holdenweb.com
Tue Oct 4 15:31:17 EDT 2005


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
> xy4223.dat
> myfile.dat
> UNQxyc123489-24.dat
> 
> only unq123abc.dat and UNQxyc123489-24.dat would be selected
> 
> I have read through the documentation and I am now sooooo
> confussedddddd!!
> 
You don't need regular expressions. You want

     list1 = glob.glob("[Uu][Nn][Qq]*.dat")

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list