Matching version number parts with regular expressions

后端 未结 6 2356
滥情空心
滥情空心 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:32

    Above answer not working properly

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

    try this one,

      var regularExpression = @"^(\d+\.)?(\d+\.)?(\d+\.)?(\*|\d+)$";
                    var regex = Regex.IsMatch("1.0.0.0", regularExpression, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                    Console.WriteLine(regex);
    

提交回复
热议问题