2013-11-22 76 views
0

我有不同的字符串,並希望從該字符串中提取日期。可能嗎???從字符串 日期圖案像通過正則表達式從字符串中提取日期

on 14th Nov. 2013 at || on 30 Nov., 2012 at 
on 24th Sept.2013  || on 7th – 9th Nov. 2012 at 
on 22nd Sept. 2013. || on 7th – 9th Nov. 2012 at 
on 16th -17th May 2013 at || on 6th March, 2013 
on 22nd March, 2013 in || on 15th March 2013 
on 15th March 2013 
+2

你是否嘗試過任何東西?你期望輸出什麼? – sp00m

+0

歡迎來到Stack Overflow!請花一分鐘閱讀[我如何問一個好問題?](http://stackoverflow.com/help/how-to-ask) – devnull

回答

0

您可以使用此:

[0-9]{1,2}(?:st|th|nd)?\s*(?:[–-]\s*[0-9]{1,2}(?:st|th|nd)?)?\s+(?:Jan\.|Feb\.|March|April|May|Juny|July|Aug\.|Sept\.|Oct.|Nov\.|Dec\.),?\s*[0-9]{4} 

但是,我不知道該月的名稱是否正確縮短。

+0

謝謝卡西米爾:) – MohsinJan110