What @danish is telling you is that you will need to try out RegEx (or regular expressions). There are tons of sites out there - MSDN; Practical Parsing; Learn Regular Expressions - just to name a few.
If you are expecting your date in only 2 specific formats, then we only have 2 patterns that we would need to match. Your example data:
FUTIDX 26FEB2009 NIFTY 0 -- There is date in the string.
FUTIDX MINIFTY 30 Jul 2009 -- There is date in the string.
FUTSTK ONGC 27 Mar 2008 -- There is date in the string.
provides us with 2 patterns:
ddMMMyyyy
dd Mmm yyyy
The example below will only look for a month in the short form. This should be enough to help you get going.
using System;
using System.Text.RegularExpressions;
namespace regexmonthtest
{
class MainClass
{
// in your class, define 2 string patterns
static string pattern = @"(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)";
public static void Main (string[] args)
{
Console.WriteLine (HasDate("FUTIDX 26FEB2009 NIFTY 0"));
Console.WriteLine (HasDate("FUTSTK MINIFTY 30 Jul 2009"));
Console.WriteLine (HasDate("FUTIDX 26api1234 NIFTY 0"));
}
public static bool HasDate (string textIn)
{
textIn = textIn.ToLower();
Console.Write(textIn + '\t');
return (Regex.Match(textIn, pattern).Success);
}
}
}
output:
futidx 26feb2009 nifty 0 True
futstk minifty 30 jul 2009 True
futidx 26api1234 nifty 0 False