I am working on a project where I am reading in a file which could come in two different formats, one includes a date and time and the other doesn\'t.
When I read i
If the format of the date has been defined, you can use Regex to solve it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace RegTest
{
class Program
{
static void Main(string[] args)
{
string testDate = "3214312402-17-2013143214214";
Regex rgx = new Regex(@"\d{2}-\d{2}-\d{4}");
Match mat = rgx.Match(testDate);
Console.WriteLine(mat.ToString());
Console.ReadLine();
}
}
}