Closed adilsoncarvalho closed 8 years ago
import re
p = re.compile('[^0-9:/-]')
p.sub(' ', u'10/11/2016 18:19:21-02:00')
# => u'10/11/2016 18:19:22-02:00'
pp = re.compile('\s+')
pp.sub(' ', u'10/11/2016 18:19:22-02:00')
# => u'10/11/2016 18:19:22-02:00'
import re
p = re.compile('[^0-9:/-]')
p.sub(' ', u'10/11/2016 \n \xe0s\n 18:19:22-02:00')
# => u'10/11/2016 18:19:22-02:00'
pp = re.compile('\s+')
pp.sub(' ', u'10/11/2016 18:19:22-02:00')
# => u'10/11/2016 18:19:22-02:00'
You can see the whole documentation here.
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
import re
r = re.compile('(\d{2})/(\d{2})/(\d{4})\s+(\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2})')
dt = r.search(u'10/11/2016 18:19:22-02:00').groups()
date = dt[2] + '-' + dt[1] + '-' + dt[0] + 'T'+dt[3]
#=> u'2016-11-10T18:19:22-02:00'
Convert bad shaped strings into date time values.
Some examples
How to find on the code
Postponed on PR #5