3
我想帶日期的正則表達式或國內首個普遍發生,我的文字的開頭:重新排序使用字符串正則表達式
例子: "I went out on 1 sep 2012 and it was better than 15 jan 2012"
,我想 "1 sep 2012, I went out on and it was better than 15 jan 2012"
我在想用",1 sep 2012,"
更換"1 sep 2012"
,然後從","
切斷繩子,但我不知道寫什麼,而不是replace_with
:
line = re.sub(r'\d+\s(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s\d{4}', 'replace_with', line, 1)
有幫助嗎?
您使用哪種語言? – Cerbrus
Python,可能。 –
您沒有使用足夠的捕獲組... – 2013-01-04 08:09:25