fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4.  
  5. namespace ConsoleApplication6
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. Console.WriteLine(ReadDouble("xxx","xxx = 24124,34"));
  12. Console.WriteLine(ReadDouble("xxx", "xxx = 24124,34e-6"));
  13. Console.WriteLine(ReadDouble("xxx", "xxx = -24124,34"));
  14. Console.WriteLine(ReadDouble("xxx", "xxx = +24124,34"));
  15. Console.WriteLine(ReadDouble("xxx", "xxgx = 24124,34"));
  16. }
  17.  
  18. static double ReadDouble(string name, string wholeFile)
  19. {
  20. string pattern = name + @"\s*=\s*([+-]?\d+((\,\d+)([eE]-?\d+)?)?)\s*$";
  21. string someDouble= Regex.Match(wholeFile, pattern).Groups[1].Value;
  22. return someDouble == string.Empty ? 0d:double.Parse(someDouble);
  23. }
  24. }
  25. }
  26.  
Success #stdin #stdout 0.09s 24584KB
stdin
Standard input is empty
stdout
2412434
2.412434
-2412434
2412434
0