title: escape special characters with regex and javascript
body: <p>I have this password cookie, the password can contain special characters. (I know it is unsafe, but this is for e-learning purposes/workaround)</p>
  
  <pre><code>var password = document.cookie.replace(/(?:(?:^|.*;\s*)password\s*\=\s*([^;]*).*$)|^.*$/, "$1");
  </code></pre>
  
  <p>My issue is that it returns the special characters like this e.g:
  <strong>! turns out as %21</strong></p>
  
  <p>I know that I should somehow, escape the special characters using regex, but I just seem not to be able to fix it.</p>
  
  <p>If the password is: <strong>p4sSW0rd!!</strong> it must be returned as: <strong>p4sSW0rd!!</strong> when I for instance alert() it.</p>