开发者

What regex matches this type of timestamp

I've got a log file with the following time stamp 开发者_如何学Cformat:

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...


A simple pattern can be:

^\w+\s\d\d\s\d\d:\d\d:\d\d\.\d+

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):

^\w+\s\d\d?\s\d\d?:\d\d?:\d\d?\.\d+


How about

/^[A-Z][a-z]{2,} \d{2} \d{2}:\d{2}:\d{2}\.\d{6}$/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜