title: Obfuscating passwords with single quotes in regex
body: <p>I am trying to rexex</p>
  
  <pre><code>PASSWORD 'dsfad'
  paSsword       'asdfa'
  PAssWord   'asdrd'''
  password  'asd''asdf'; password 'asdf'
  </code></pre>
  
  <p>to become</p>
  
  <pre><code>password '*****'
  password '*****'
  password '*****'
  password '*****'
  password '*****'; password '*****'
  </code></pre>
  
  <p>I have tried the following </p>
  
  <pre><code>re.compile("password\s*'[^']+['|''']", re.IGNORECASE).sub("password '*****'", "PASSWORD 'adfsdf'  password   'dadaskjh'    PaSsWoRd 'kkj''hjubkjn'''")
  re.compile("password\s*'[^']+'", re.IGNORECASE).sub("password '*****'", "PASSWORD 'adfsdf'  password   'dadaskjh'    PaSsWoRd 'kkj''hjubkjn'''")
  </code></pre>
  
  <p>though it seems to be having trouble with the extra <code>'</code> and stopping the regex revealing half of the password. </p>
  
  <p>EDIT:</p>
  
  <p>These passwords are from postgres logs. The double <code>''</code> is escaping.</p>