You should use regular expression. Here is a link
http://www.regular-expressions.info/[
^]
The regular expression should be:
const string expresion = @"(0[1-9]|[12][0-9]|3[01])(0[1-9]|1[012])(19|20)\d\d";
Then in your code you should use:
foreach (Match match in Regex.Matches(yourString, expresion ))
{
string dateString = match.Value;
string dd = dateString.Substring(0,2);
string mm= dateString.Substring(2,2);
string yyyy= dateString.Substring(4,4);
}
Note that the code above is generally and could match more then one date in your input string. If you want to manage only the first occurrence you could use
if
in place of
foreach
!