且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用示例在vb中使用正则表达式创建日期格式

更新时间:2023-11-29 11:27:16

不要。

您可以编写一个正则表达式来验证日期: http://www.regular-expressions .info / dates.html [ ^ ] ...但这对于问题来说是一个糟糕的解决方案。



相反,使用 DateTime.TryParseExact [ ^ ]这样更容易阅读,甚至可以将其转换为DateTime值供您使用将来!
Don't.
You can write a regex to validate a date: http://www.regular-expressions.info/dates.html[^]...but it's a poor solution to teh problem.

Instead, use DateTime.TryParseExact[^] which is a lot easier to read, and even converts it to a DateTime value for you to use in future!