title: Swift Regex with special Characters
body: <p>I am attempting to use this string: </p>
  
  <pre><code>var passwordRegex = "^[A-Za-z0-9 !\"#$%&amp;'()*+,-./:;&lt;=&gt;?@[\\]^_`{|}~].{8,}$"
  </code></pre>
  
  <p>As my regular expression pattern, but it keeps failing saying the pattern is invalid. I used the <code>\</code> character to escape for the characters: <code>"</code> and <code>\</code>, but it throws the error: <code>invalid escape sequence in literal</code> for regex key characters like <code>^ &amp; [ ] | .</code> etc. </p>
  
  <p>What am I missing in order to allow the characters: </p>
  
  <pre><code> ! " # $ % &amp; ' ( ) * + , - . / : ; &lt; = &gt; ? @ [ \ ] ^ _ ` { | } ~   
  </code></pre>
  
  <p>(including space) in my regex? I assume it's something with how I am escaping, but I can't find anything anywhere for these characters in regards to SWIFT's regular expression.</p>