/* * Your a/c 594585 is debited INR 354.00 on 21-11-2014 17:45:31 Info PUR/HyperCity/Bangalore * */ //Using array //Change the location of the file //eliminates the risk of space after specic keywords. Prevent adding it to the result which we want //eg . INR 500 => myt coz space500 to save... this is eliminated using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace Parse { class Program2 { static void Main(string[] args) { string [] q = new string[100]; string account=""; string amount=""; string date = ""; string location = ""; string [] lines = File.ReadAllLines(@"C:\Users\slahoti2\New folder\Parse\Parse\sms.txt"); string[] words = lines[0].Split(' '); int length = words.Length; for (int i = 0; i < length; i++) { if (words[i] == "a/c") account = words[i + 1]; if (words[i] == "INR") amount = words[i + 1]; if (words[i] == "on") date = words[i + 1]; if (words[i] == "Info") location = words[i + 1]; } Console.WriteLine("Account : " + account + " Amount : Rs " + amount+" Date : "+ date +" Location : "+location); Console.ReadKey(); } } }