is_semantic_version()

audeer.is_semantic_version(version)[source]

Check if given string represents a semantic version.

To be a semantic version your version has to comply to X.Y.Z or vX.Y.Z, where X, Y, Z are all integers. Additional version information, like beta has to be added using a - or +, e.g. X.Y.Z-beta.

Parameters

version (str) – version string

Return type

bool

Returns

True if version is a semantic version

Examples

>>> is_semantic_version("v1")
False
>>> is_semantic_version("1.2.3-r3")
True
>>> is_semantic_version("v0.7.2-9-g1572b37")
True