using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\d+\.\d+(\.[\d]+)?";
string input = @"/Versionnr: 5.131 //should be 5.13
/Versionname: somename v5.13b1
/Versionnr: 2.0..4 //should be 2.0
/Versionname: another name 2 v2.0.exp.4
/Versionnr: 18.01 //should be 18.0
/Versionname: somename v18.0-ALPHA1
/Versionnr: 7.2.42221..3634639 //should be 7.2.4222
/Versionname: another name v7.2.4222-1.L.3634639
/Versionnr: 5.0.220170112 //should be 5.0.2
/Versionname: somename v5.0.2 build 20170112
/Versionnr: 4.4.0.201701124401 //should be 4.4.0
/Versionname: another name v4.4.0.20170112b4401";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx