From Sourav, 10 Years ago, written in Plain Text.
Embed
  1. /*
  2.  * Your a/c 594585 is debited INR 354.00 on 21-11-2014 17:45:31 Info PUR/HyperCity/Bangalore
  3.  * */
  4.  
  5. //Using array
  6. //Change the location of the file
  7. //eliminates the risk of space after specic keywords. Prevent adding it to the result which we want
  8. //eg . INR 500 => myt coz space500 to save... this is eliminated
  9.  
  10.  
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.IO;
  16.  
  17. namespace Parse
  18. {
  19.     class Program2
  20.     {
  21.         static void Main(string[] args)
  22.         {
  23.             string [] q =  new string[100];        
  24.             string account="";
  25.             string amount="";
  26.             string date = "";
  27.             string location = "";
  28.             string [] lines = File.ReadAllLines(@"C:\Users\slahoti2\New folder\Parse\Parse\sms.txt");
  29.             string[] words = lines[0].Split(' ');
  30.             int length = words.Length;
  31.             for (int i = 0; i < length; i++)
  32.             {
  33.                
  34.                 if (words[i] == "a/c")
  35.                     account = words[i + 1];
  36.                 if (words[i] == "INR")
  37.                     amount = words[i + 1];
  38.                 if (words[i] == "on")
  39.                     date = words[i + 1];
  40.                 if (words[i] == "Info")
  41.                     location = words[i + 1];
  42.             }
  43.                 Console.WriteLine("Account : " + account + " Amount : Rs " + amount+" Date : "+ date +" Location : "+location);
  44.                 Console.ReadKey();
  45.  
  46.                
  47.         }
  48.     }
  49. }
  50.