pattern match !

Helmut Jarausch jarausch at igpm.rwth-aachen.de
Wed Jul 11 07:29:40 EDT 2007


hari.siri74 at gmail.com wrote:
> Extract the application name with version from an RPM string like
> hpsmh-1.1.1.2-0-RHEL3-Linux.RPM, i require to extract hpsmh-1.1.1.2-0
> from above string. Sometimes the RPM string may be hpsmh-1.1.1.2-RHEL3-
> Linux.RPM.
> 

Have a try with

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)



-- 
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany



More information about the Python-list mailing list