On Jul 11, 9:29 pm, Helmut Jarausch <[EMAIL PROTECTED]>
wrote:
> import re
> P=re.compile(r'(\w+(?:[-.]\d+)+)-RHEL3-Linux\.RPM')
> S="hpsmh-1.1.1.2-0-RHEL3-Linux.RPM"
> PO= P.match(S)
> if  PO :
>    print PO.group(1)

Isn't a regexp overkill here when this will do:

head = filename[:filename.index('-RHEL3')]

Of course if you need to make it more generic (as in Jay's solution
below), re is the way to go.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to