title: How to Escape Characters in String in Firestore Rules?
body: <p>I'm trying to check if an incoming string is an email, so I wrote the following Firestore Security Rules:</p>
  
  <pre><code>service cloud.firestore {
      match /databases/{database}/documents {
          match /signups/{uid} {
              // RegExp copied from https://www.regextester.com/19
              allow create: if newData().email.matches("^[a-zA-Z0-9.!#$%&amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$");
          }
      }
  }
  </code></pre>
  
  <p>But when I deploy it using <code>firebase deploy --only firestore</code>:</p>
  
  <pre><code>=== Deploying to '[my-project-id]'...
  
  i  deploying firestore
  i  firestore: checking firestore.rules for compilation errors...
  i  firestore: reading indexes from firestore.indexes.json...
  
  Error: Compilation errors in firestore.rules:
  [E] 5:139 - Unexpected '['.
  [E] 5:149 - Unexpected ']'.
  [E] 5:151 - token recognition error at: '?'
  [E] 5:171 - Unexpected '['.
  [E] 5:183 - token recognition error at: '?'
  [E] 8:1 - Unexpected '}'.
  </code></pre>
  
  <p>Here is the screenshot on the Firebase Console:</p>
  
  <p><a href="https://imgur.com/a/LDTvB2K" rel="nofollow noreferrer">https://imgur.com/a/LDTvB2K</a></p>
  
  <p>Apparently, the RegExp string ends at the <code>'</code> character (5:73). How can I escape the string in Firestore Rules? I cannot find any documentation on this problem.</p>