Matching version number parts with regular expressions

后端 未结 6 2330
滥情空心
滥情空心 2021-02-15 14:28

I\'m trying to match the parts of a version number (Major.Minor.Build.Revision) with C# regular expressions. However, I\'m pretty new to writing Regex and even using Expresso is

6条回答
  •  囚心锁ツ
    2021-02-15 14:39

    Try something like this:

    (?\d*)\.?(?\d*)?\.?(?\d*)?\.?(?\d*)?

    I simply added some "zero or one" quantifiers to the capture groups and also to the dots just in case they are not there.

提交回复
热议问题