Matching version number parts with regular expressions

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

    Tested in VBScript, this pattern:

    ^(\d+)(\.\d+)?(\.\d+)?(\.\d+)?$
    

    Will validate all the following True:

    • 23
    • 23.1
    • 23.1.1
    • 23.1.1.1

    And the following all False:

    • 23.11.11.33.11
    • 23.43 2.1
    • 44.11.2 3
    • 3q.4.2.1
    • 3.4.
    • 4.3.21a

提交回复
热议问题