def _find_matching_version(versions, version_pattern):
pattern = fnmatch.translate(version_pattern.replace('<STR_LIT:x>', '<STR_LIT:*>'))<EOL>return next((v for v in versions if re.match(pattern, v)), None)<EOL>
Return the first matching version

>>> _find_matching_version(['1.1.4', '1.0.12', '1.0.5'], '1.0.x')
'1.0.12'

>>> _find_matching_version(['1.1.4', '1.0.6', '1.0.5'], '2.x.x')