title: Replace datetime characters in a string
body: <p>Consider the following example <code>str</code> of dates: </p>
  
  <p><code>'20180101,20180102,20180103,20180104,20180105,20180106,20180107,20180108,20180109,20180110,20180111,20180112,20180113,20180114,20180115,20180116,20180117,20180118,20180119,20180120,20180121,20180122,20180123,20180124,20180125,20180126,20180127,20180128,20180129,20180130,20180131,20180201,20180202,20180203,20180204,20180205,20180206,20180207,20180208'</code>.</p>
  
  <p>Using <code>.replace('2018','2018-')</code>, or <code>re.sub('2018', '2018-', foo_string)</code> from the module <code>re</code>, a date changes to <code>2018-0101</code>. However, I'd like to insert a hyphen for a range of dates. I have tried the following <code>re.sub('{}'.format(range(2018,2019)), '2018-', foo_string)</code> to no avail. The string is returned without any changes. For reference the years I'd like to range over for the hyphen are 1981 to 2018. </p>
  
  <p>Additionally, I'm unsure of a way to insert a hyphen between the month and dates in a clean way. Help along these directions would be greatly appreciated.</p>