Using regex in Python to insert a space between a date and time -


i have list of dates , times in following format: 25/07/201711:00:00 want insert whitespace between date , time looks like: 25/07/2017 11:00:00

the string replace method works not robust i.e. mystring.replace("2017","2017 " ) works 2017 dates. regex sub method seems need use have not been successful far. suggestions helpful regex knowledge limited.

this closest have tried:

>>>re.sub(r'20[0-9][0-9]', r'20[0-9][0-9] ', s) '20[0-9][0-9] 04:00' 

if dates in 'dd/mm/yyyy' format, why can't index string?

>>> mystring[:10] + ' ' + mystring[10:] '25/07/2017 11:00:00' 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -