You have too many problems here, even though the problem is extremely simple. First of all, '.' is a special Regular Expression notation. So, escape it: '\.'.
Take each '[0-9]' term in round brackets, it will help you to get set of
matches and later parse each of the matches into integer. And finally, do you really want to have only one digit in each version component? I doubt it. Add multiplicity: '+' (which means 1 or more). Oh, and I almost forgot: add ^ at the beginning and $ at the end.
I hope after I described all your mistakes, you can easily solve the problem.
See also:
https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/e7sf90t3(v=vs.110).aspx[
^],
https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchcollection%28v=vs.110%29.aspx[
^].
Note that I referenced the method
Matches
, not
Match
. This is what you really want, because you need to match each part of the version separately and parse all matches separately.
But I would solve the problem much simpler:
string[] versionParts = versionString.Split('.');
—SA