title: Python re.sub giving error: invalid group reference
body: <p>I know this was covered elsewhere but my use case is causing me difficulty.</p>
  
  <p>What if a string has a dreaded "\3" character like this one:</p>
  
  <pre><code>new_data = r'C:\temp\3_times.csv'
  </code></pre>
  
  <p>...then re "thinks" that you're referring to it as a group so if you try to do a sub using that data then you get this error:</p>
  
  <pre><code>newfiledata = re.sub(old_data,new_data,filedata)
  
  error: invalid group reference
  </code></pre>
  
  <p>Is there any way to avoid this error without looking for that case in the string and modifying it directly before passing it which would take lots of extra code.</p>
  
  <p>Note: For the usage I'm going for modifying the string with escape characters isn't an option because I need to write the string with the sub function later on. So this is not a duplicate of the question on how to escape special characters.</p>