using System; using System.Text.RegularExpressions; namespace ConsoleApplication6 { class Program { static void Main(string[] args) { Console.WriteLine(ReadDouble("xxx","xxx = 24124,34")); Console.WriteLine(ReadDouble("xxx", "xxx = 24124,34e-6")); Console.WriteLine(ReadDouble("xxx", "xxx = -24124,34")); Console.WriteLine(ReadDouble("xxx", "xxx = +24124,34")); Console.WriteLine(ReadDouble("xxx", "xxgx = 24124,34")); } static double ReadDouble(string name, string wholeFile) { string pattern = name + @"\s*=\s*([+-]?\d+((\,\d+)([eE]-?\d+)?)?)\s*$"; string someDouble= Regex.Match(wholeFile, pattern).Groups[1].Value; return someDouble == string.Empty ? 0d:double.Parse(someDouble); } } }