如何使正则表达式匹配01h20:58 UTC? [英] How do I make a regular expression match 01h20:58 UTC?

查看:141
本文介绍了如何使正则表达式匹配01h20:58 UTC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题在标题中。我需要每小时一分钟和第二匹配。

My question is in the title. I need every hour minute and second matched.

推荐答案

这很容易,但你最好做一些非常不同的事情。使用 System.DateTime.TryParseExact 方法之一: https://msdn.microsoft.com/en-us/library/system.datetime.tryparseexact%28v=vs.110%29.aspx [<一个href =https://msdn.microsoft.com/en-us/library/system.datetime.tryparseexact%28v=vs.110%29.aspxtarget =_ blanktitle =New Window> ^ ]。



指定所需的样式和确切格式:

https://msdn.microsoft.com/en-us/library/8kb3ddd4(v = vs.110)的.aspx [ ^ ],

https://msdn.microsoft .com / zh-cn / library / az4se3k1(v = vs.110).aspx [ ^ ]。



尝试解析后,如果输入字符串与模式匹配,您将看到函数返回。



-SA
This is easy, but you should better do something very different. Use one of the System.DateTime.TryParseExact methods: https://msdn.microsoft.com/en-us/library/system.datetime.tryparseexact%28v=vs.110%29.aspx[^].

Specify the styles and exact format you need:
https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx[^].

After the parse is attempted, you will see by the function return if the input string matches the pattern or not.

—SA


这篇关于如何使正则表达式匹配01h20:58 UTC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆