且构网

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

如何为 MM:DD:YYYY:HH:MM:SS 编写正则表达式

更新时间:2023-02-26 13:48:21

如果您想捕获月、年、...的值,您可以使用这样的方法,我想:

If you want to capture the values for month, year, ... you could use something like this, I suppose :

([0-9]{2}):([0-9]{2}):([0-9]{4}):([0-9]{2}):([0-9]{2}):([0-9]{2})


如果您的正则表达式引擎支持,\d 可以用作 [0-9] 的别名:


If supported by your regex engine, \d can be used as an alias to [0-9] :

(\d{2}):(\d{2}):(\d{4}):(\d{2}):(\d{2}):(\d{2})