Regular expression for date pattern yyyy-mm-dd

Regular expression for date pattern yyyy-mm-dd  

Regular expression for date pattern [yyyy/mm/dd] can return date pattern like 2012/01/31. Here we will see both [C#] and examples.

Regex for date pattern yyyy-mm-dd

Let's see C# program with regular expression pattern @"\d{4}/\d{2}\/\d{2}\/". You can strip out  last forward slash from it to exclude it from filtration rule.

using System;
using System.Text.RegularExpressions;

namespace Csharp.Regularexpresison.Pattern.Date
  class Program
    static void Main(string[] args)

      string InputDate = "/post/2012/12/20/default.aspx";

      string pattern = @"\d{4}/\d{2}\/\d{2}\/";
      Regex re = new Regex(pattern);



C# program output. First output returns found date and second replaces the found date in input string with blank.

/post/default.aspx program for getting date pattern from string.

Imports System
Imports System.Text.RegularExpressions

Namespace Csharp.Regularexpresison.Pattern.Date
	Class Program
		Private Shared Sub Main(args As String())

			Dim InputDate As String = "/post/2012/12/20/default.aspx"

			Dim pattern As String = "\d{4}/\d{2}\/\d{2}\/"

			Dim re As New Regex(pattern)


			Console.WriteLine(InputDate.Replace(re.Match(InputDate).Value, ""))

		End Sub
	End Class
End Namespace


C# Regular Expression Get Text Between BracketsDateTimeTryParse using C# and exampleC# DateTime Cache ObjectC# Parse method of DateTimeDateTime.Today Vs DateTime.NowRegular Expression For AlphanumericC# DateTime ToString()DateTime in C# current Date and TimeC# DateTimeRegular expression for getting words from string


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.