Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace MatchDateUsingRegex
- {
- using System;
- using System.Text.RegularExpressions;
- public class MatchDateUsingRegex
- {
- public static void Main()
- {
- string text = "Today is 2016-06-09";
- string pattern = @"\d{4}-\d{2}-\d{2}";
- Regex regex = new Regex(pattern);
- bool containsValidDate = regex.IsMatch(text);
- Console.WriteLine(containsValidDate); //true
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment