日付または通常は正規表現の最初の出現をテキストの先頭に移動したい:
例:
"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)
助けはありますか?