{"action":"opened","issue":{"url":"https://api.github.com/repos/ihiji/version_utils/issues/7","repository_url":"https://api.github.com/repos/ihiji/version_utils","labels_url":"https://api.github.com/repos/ihiji/version_utils/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/ihiji/version_utils/issues/7/comments","events_url":"https://api.github.com/repos/ihiji/version_utils/issues/7/events","html_url":"https://github.com/ihiji/version_utils/issues/7","id":144215264,"number":7,"title":"version_utils: incorrect handling of epoch in _rpm_re regex","user":{"login":"thoger","id":4051912,"avatar_url":"https://avatars.githubusercontent.com/u/4051912?v=3","gravatar_id":"","url":"https://api.github.com/users/thoger","html_url":"https://github.com/thoger","followers_url":"https://api.github.com/users/thoger/followers","following_url":"https://api.github.com/users/thoger/following{/other_user}","gists_url":"https://api.github.com/users/thoger/gists{/gist_id}","starred_url":"https://api.github.com/users/thoger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoger/subscriptions","organizations_url":"https://api.github.com/users/thoger/orgs","repos_url":"https://api.github.com/users/thoger/repos","events_url":"https://api.github.com/users/thoger/events{/privacy}","received_events_url":"https://api.github.com/users/thoger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-29T09:55:36Z","updated_at":"2016-03-29T09:55:36Z","closed_at":null,"body":"The `_rpm_re` regular expression is used to split RPM nvr or nevr to name, epoch, version and release.  However, the regex is incorrect and likely to treat part of the version number as epoch number, as it only handles `:` as optional, rather than whole `(\\d*):`.\r\n\r\n~~~\r\n>>> from version_utils import rpm\r\n>>> pkg = rpm.package('firefox-45.0-4.fc22.x86_64')\r\n>>> print pkg.epoch, pkg.version\r\n4 5.0\r\n~~~\r\n\r\nwhile the expected output is:\r\n\r\n~~~\r\n0 45.0\r\n~~~\r\n\r\nI think the relevant part of the regex should be `(?:(\\d*):)?`.  Non-capturing group is used to avoid further changes to `parse_package()`.  However, the following still needs fixing:\r\n\r\n~~~\r\nepoch = default_epoch if epoch == '' else epoch\r\n~~~\r\n\r\nto check `if epoch is None`."}}