Guest User

Untitled

a guest
Jan 3rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. public static void Main()
  2. {
  3. String pattern = "FL2 (77) Flashing,77,a=1.875,A=90.0,b=3.625,B=95.0,c=1.375,C=175.0,d=2.5,hem=0.5,16GA-AL,";
  4. string[] fParams = pattern.Split(',');
  5. Regex regex = new Regex("([a-zA-Z]=.*?)");
  6.  
  7. for (int i = 0; i < fParams.Length; i++)
  8. {
  9. if (regex.IsMatch(fParams[i]))
  10. {
  11. Console.WriteLine("true " + fParams[i]);
  12. if (fParams[i].Any(char.IsUpper))
  13. {
  14. Console.WriteLine("upper case", fParams[i]);
  15. string[] param = fParams[i].Split('=');
  16. // Note in actual program I do more complex calculations
  17. Double value = Math.Round(Convert.ToDouble(param[1]));
  18. pattern = pattern.Replace(fParams[i], param[0]+"="+Convert.ToString(value));
  19. }
  20. else
  21. {
  22. Console.WriteLine("lower case", fParams[i]);
  23. string[] param = fParams[i].Split('=');
  24. // Note in actual program I do more complex calculations
  25. Double value = Math.Round(Convert.ToDouble(param[1]) * 2) / 2;
  26. pattern = pattern.Replace(fParams[i], param[0] + "=" + Convert.ToString(value));
  27. }
  28.  
  29. }
  30. }
  31.  
  32. //return pattern;
  33. }
Add Comment
Please, Sign In to add comment