title: Replacing string text in python w/ regex, re, or str.replace
body: <p>Hi I'm looking for some help replacing a certain string pattern in my data.  I have a massive list of json data from an API, however, it appears a date field is being returned as a python function before having been parsed out into raw text.  Below is an example of the <code>started_at</code> attribute in the raw json data which is causing me problems:</p>
  <p><code>'started_at': datetime.datetime(2022, 2, 7, 16, 37, 26)</code></p>
  <p>Like instead of the actual date + timestamp in raw text, it's just represented as the python function.  When I try running json.loads() on this data, it fails because of this attribute not being properly parsed out.  So my potential solution is I want to replace the <code>datetime.datetime(2022, 2, 7, 16, 37, 26)</code> text with a simple variable like <code>current_date = str(datetime.now().date())</code>, so it will just be <code>2022-02-07</code> instead of the whole datetime string.</p>
  <p>I've tried doing <code>raw_json.replace(datetime.datetime(*, *, *, *, *, *), current_date)</code>, but it doesn't work because I'm not sure how to manipulate the regex in a way so that it captures ANY pattern in that format.</p>
  <p>Putting in some reproducible code below if anybody wants to try it out:</p>
  <pre><code>import re
  from datetime import datetime
  
  current_date = str(datetime.now().date())
  sample_json = str({'started_at': 'datetime.datetime(2022, 2, 7, 16, 37, 26)'})
  
  
  formatted_json = sample_json.replace('datetime.datetime(*, *, *, *, *, *)', current_date)
  
  </code></pre>