C#で次のことを行うにはどうすればよいですか:
var re = /^\d{4}(\/\d{2}){2} \d{2}(:\d{2}){2}$/;
re.test('2013/03/05 15:22:00'); // returns true
C#で次のことを行うにはどうすればよいですか:
var re = /^\d{4}(\/\d{2}){2} \d{2}(:\d{2}){2}$/;
re.test('2013/03/05 15:22:00'); // returns true
Regex.IsMatch
代わりに ( docs )を使用できます。
Regex.IsMatch("2013/03/05 15:22:00", @"^\d{4}(\/\d{2}){2} \d{2}(:\d{2}){2}$"); // true if match
以下のコードで、目的の場所に移動できます。
Regex rx = new Regex(@"^\d{4}(\/\d{2}){2} \d{2}(:\d{2}){2}$");
String test = "2013/03/05 15:22:00";
if (rx.IsMatch(test))
{
//Test String matches
}
else
{
//Test String does not match
}