Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int HowManyDecimal(string input)
- {
- input = input.Substring(input.IndexOf('.') + 1);
- if (input.Contains("E"))
- {
- input = input.Remove(input.IndexOf('E'));
- }
- return input.Length;
- }
- bool IsDate(ref string input)
- {
- return input.Contains("-") && !input.Contains("E");
- }
- bool IsTime(ref string input)
- {
- return input.Contains(":");
- }
- bool IsMeasure(ref string input)
- {
- return HowManyDecimal(input) == 2;
- }
- bool IsLocation(ref string input)
- {
- return HowManyDecimal(input) == 3;
- }
- bool IsResult(ref string input)
- {
- return input[0] == 'A' || input[0] == 'R';
- }
- string Date ="";
- string Time = "";
- string Measure = "";
- string Location = "";
- string Result = "";
- string Input2 = "2019-10-29\t17:45:21\t3.44E-6\t5.454\tReject\r\n";
- string Input3 = "2019-10-29\t17:45:21\t0.00\t5.454\tReject\r\n";
- string Input = "2019-10-29\t3.44E-6\t5.454\tReject\r\n";
- string Input5 = "17:45:21\t3.44E-6\t5.454\tReject\r\n";
- string Input4 = "17:45:21\t5.454\tReject\r\n";
- string Input6 = "5.454\tReject\r\n";
- string[] strlist = Input.Split("\t");
- for(int i = 0; i < strlist.Length; i++)
- {
- if (IsDate(ref strlist[i]))
- Date = strlist[i];
- else if(IsTime(ref strlist[i]))
- Time = strlist[i];
- else if (IsMeasure(ref strlist[i]))
- Measure = strlist[i];
- else if (IsLocation(ref strlist[i]))
- Location = strlist[i];
- else if (IsResult(ref strlist[i]))
- Result = strlist[i];
- }
- Console.WriteLine("Date: " + Date + "\n" + "Time: " + Time + "\n" + "Measure: " + Measure + "\n" + "Location: " + Location + "\n" + "Result: " + Result + "\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement