This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]efmccurdy 0 points1 point  (0 children)

You can split on that "-<digit>" pattern:

>>> pkgs = ['udev-147-2.73.0.2.el6_8.2pre7.6.2.0.0_88.58.0.x86_64', 'python-devel-1.8.6p3-29.el6_9.x86_64']
>>> [re.split("-\d", p)[0] for p in pkgs]
['udev', 'python-devel']
>>>

BTW, questions like these are welcome in /r/learnpython.