I am trying to get the highest version of a string in Python. I was trying to sort the list but that of course doesnt work as easily as Python will sort the string representation.
For that I am trying to work with regex but it somehow doesnt match.
The Strings look like this:
topic_v10_ext2
topic_v20_ext2
topic_v2_ext2
topic_v5_ext2
topic_v7_ext2
My Regex looks like this.
version_no = re.search("(?:_v([0-9]+))?", v.name)
I was thinking about saving the names in a list and look for the highest v_xx in the list to return. Also for now I am doing this in two FOR loops. Which runs in 2*O(log(n)) which is not optimal I believe. How can I get the highest version in a fast and simple way?
extpart of the version number?topic_v…be strings??at the end.