title: Escape regex literal in Google Apps Script
body: <p>I have no idea why this isn't working - I've put it through one of the better regex tools I've found on the web to verify it, and I'm using what seems to be the escape character '\' before the + sign to make it a literal '+', but Google Scripts keeps complaining saying "Invalid Quantifier '+'" (Line 2)</p>
  
  <p>Here's my script, with certain personal details (it's to clean out email as I use this account as a hard spam filter) omitted:</p>
  
  <pre><code>function getEmailData() {
    var find_email_regex = new RegExp("myemail(\+.*|)\@gmail.com");
    var emails = GmailApp.getChatThreads();
    var process_email = "";
    try {
      for (i = 0; i &lt; emails.length; i++) {
        for (x = 0; x &lt; emails[i].getTo().length; x++) {
          if (emails[i].getTo()[x].matches(find_email_regex)) {
            email_triage(emails[i]);
            break;
          }
        }
      }
    } catch (e) {}
  }
  
  function email_triage(email) {
    var reject_regex = new RegExp("^[^\+]*$");
    try {
      if (email.matches(reject_regex)) {
        email.moveThreadToTrash();
      }
      else {
        email.getMessages()[0].forward("mymainemail@email.ca");
      }
    } catch (e) {}
  }
  </code></pre>
  
  <p>Is there any obvious reason as to why it keeps saying invalid quantifier?
  My objective is to regex two variations of my address, since a spammer might send an email with a large list, and I only want to parse my email out of it for further processing.</p>
  
  <p>It needs to handle:
  myemail+stuff@gmail.com
  myemail@gmail.com</p>
  
  <p>Hence the literal, but I have no luck with it. Please assist, thank you.</p>