On 31 Jan 2005, [EMAIL PROTECTED] wrote:
>
> Slight correction which I realized after sending, see below for
> version/release seperation, which I should have seen but blame lack of
> sleep ;-)
> corrected versions:
> 4.3.0
> 3.2.3d
> 3
> 5.42a
> 1.10
>
> (new) releases:
> 78.EL
> 12
> 4
> 0
> 16.9.EL
>
>
>> arches:
>> i386,
>> i386,
>> noarch,
>> noarch,
>> i386
The regexp for the above could be:
reg = sre.compile(
r'''
(?P<name>
^[-\w]+ # name is the match in our string which can consist of
# nearly everything
(\.\D[-\w]+?)?) # if it contains a point it is followed by a non-digit char
# we search till we find
- # a hyphen
(?P<version>
\d+(\.\w+)*) # a version consists of digits and points
# we search till we find
- # a hyphen
(?P<release>
[\d.]+(EL)?) # release consists of digits seperated by a point and ends
# optionally with EL
\.(\w*\.)? # no comes a point and optionally a string
(?P<arch>
\w+?) # arch is the shortest everything between .rpm and the point
\.rpm$'''
, sre.X)
,----
| >>> for name in names:
| m = reg.search(name)
| print m.groupdict()
| ... ... ...
| {'release': '78.EL', 'version': '4.3.0', 'arch': 'i386', 'name':
'XFree86-ISO8859-15-75dpi-fonts'}
| {'release': '12', 'version': '3.2.3d', 'arch': 'i386', 'name': 'xfig'}
| {'release': '4', 'version': '3', 'arch': 'noarch', 'name':
'rhel-ig-ppc-multi-zh_tw'}
| {'release': '0', 'version': '5.42a', 'arch': 'noarch', 'name':
'perl-DateManip'}
| {'release': '16.9.EL', 'version': '1.1.0', 'arch': 'i386', 'name':
'openoffice.org-style-gnome'}
| >>>
`----
Karl
--
Please do *not* send copies of replies to me.
I read the list
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor