什么正则表达式匹配这种类型的时间戳
我有一个具有以下时间戳格式的日志文件:
May 02 13:27:15.722996
我应该使用什么正则表达式来匹配它?即从两百个字符的行中我只想返回这个特定的字符串 - 它始终位于行的开头......
I've got a log file with the following time stamp format:
May 02 13:27:15.722996
What regex should I use to match that? i.e. from a two hundred character line I just want to return this particular string - it's always at the beginning of the line...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个简单的模式可以是:
没什么大不了的,真的。您可以将
\d
替换为[0-9]
,或者稍微压缩一下,但它非常简单。您可能还希望将某些数字设为可选,以防您没有前导零(例如,May 3 1:2:3.34
):A simple pattern can be:
Not much to it, really. You can replace
\d
with[0-9]
, or maybe compact it a little, but it's pretty straightforward. You may also want to make some of the digits optional, in case you don't have leading zeros (May 3 1:2:3.34
, for example):怎么样
How about