Guest User

Untitled

a guest
Jan 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. 2X + 5Y + z^3
  2.  
  3. int thirdValue
  4. string temp;
  5. temp = Regex.Match(variables[3], @"d+").Value
  6. thirdValue = int.Parse(temp);
  7.  
  8. string temp = textBox1.Text;
  9. char[] arra = temp.ToCharArray();
  10. int total = 0;
  11. foreach (char t in arra)
  12. {
  13. if (char.IsDigit(t))
  14. {
  15. total += int.Parse(t + "");
  16. }
  17. }
  18. textBox1.Text = total.ToString();
  19.  
  20. string temp;
  21. temp = Regex.Matches(textBox1.Text, @"d+", RegexOptions.IgnoreCase)[2].Value;
  22. int thirdValue = int.Parse(temp);
  23.  
  24. static class Program
  25. {
  26. static void Main()
  27. {
  28.  
  29. Console.WriteLine("2X + 65Y + z^3".GetNumbersFromString().Sum());
  30.  
  31. Console.ReadLine();
  32. }
  33.  
  34.  
  35. static IEnumerable<int> GetNumbersFromString(this string input)
  36. {
  37. StringBuilder number = new StringBuilder();
  38. foreach (char ch in input)
  39. {
  40. if (char.IsDigit(ch))
  41. {
  42. number.Append(ch);
  43. }
  44. else if (number.Length > 0)
  45. {
  46. yield return int.Parse(number.ToString());
  47. number.Clear();
  48. }
  49. }
  50. yield return int.Parse(number.ToString());
  51. }
  52. }
  53.  
  54. Regex.Match(variables[3], @"d+").Value
  55.  
  56. if (Regex.IsMatch(variables[3], @"d+")){
  57. temp = Regex.Match(variables[3], @"d+").Value
  58. }
Add Comment
Please, Sign In to add comment