2012-07-16 148 views
-4

正則表達式我想要的正則表達式此日期格式 週三7月16日00:00:00 UTC 2008日期格式

+0

請使用您所用語言的實用程序來讀取日期。 – nhahtdh 2012-07-16 08:09:17

+1

1.爲什麼你需要一個**正則表達式**? 2.你有什麼嘗試? – poncha 2012-07-16 08:09:36

+0

首先,您需要嘗試一些內容,如果您在某處發現問題並提出建議問題。 SO用戶將爲您提供最好的建議。 – 2012-07-16 08:10:47

回答

0

使用這個表達式 ([a-zA-Z]{3}\s){2}\d{2}\s\d{2}:\d{2}:\d{2}\sUTC\s\d{4}

0
$subject = "Wed Jul 16 00:00:00 UTC 2008 Tue Jul 12 15:00:04 UTC 2009"; 
$pattern = '![a-zA-Z]{3}\s+[a-zA-Z]{3}\s+\d{2}\s+\d{2}\:\d{2}\:\d{2}\s+[a-zA-Z]{3}\s+\d{4}!'; 
preg_match_all($pattern, $subject, $matches); 
print_r($matches); 

輸出:

Array ([0] => Array ([0] => Wed Jul 16 00:00:00 UTC 2008 [1] => Tue Jul 12 15:00:04 UTC 2009)) 
1
(?<WeekDay>\w+)\s+(?<Month>\w+)\s+(?<MonthDay>\d+)\s+(?<Hour>\d+):(?<Min>\d+):(?<Sec>\d+)\s+(?<TimeZone>\w+)\s+(?<Year>\d+) 

,並獲得該組

${WeekDay} 
${Month} 
${MonthDay} 
${Hour} 
${Min} 
${Sec} 
${TimeZone} 
${Year} 
0
EEE MMM dd HH:mm:ss z yyyy 

如果您使用JavaSimpleDateFormat