title: Google Apps Script - Using Colon in Regular Expressions
body: <p>I'm using a Google Apps Script to export form data from gmail emails. The script uses regular expressions to match on characters in the emails. Any time I discover any data that wasn't successfully exported with the script, I look for any unusual character that the script wasn't able to match on (usually diacritics). This strategy has worked well, except that I can't figure out how to match on something as simple as a colon. Any form data that includes a colon won't get downloaded by my script. Can anyone help? Simply adding a colon to the list of characters that are supposed to be matched on doesn't work. Here is the complete script. It looks at 14 different form fields.</p>
  
  <pre><code>function parseEmailMessages(start) {
  
  start = start || 0;
  
  var threads = GmailApp.getInboxThreads(start, 100);
  var sheet = SpreadsheetApp.getActiveSheet();
  
  for (var i = 0; i &lt; threads.length; i++) {
  
  // Get the first email message of a threads
  var tmp,
    message = threads[i].getMessages()[0],
    subject = message.getSubject(),
    content = message.getPlainBody();
  
  // Get the plain text body of the email message
  // You may also use getRawContent() for parsing HTML
  
  // Implement Parsing rules using regular expressions
  if (content) {
  
    tmp = content.match(/First:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var first = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
    tmp = content.match(/Last:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var last = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
    tmp = content.match(/Title:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var title = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
    tmp = content.match(/Organization:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var organization = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
    tmp = content.match(/City:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var city = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
    tmp = content.match(/State:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var state = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
    tmp = content.match(/Country:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var country = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
    tmp = content.match(/Affiliation:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var affiliation = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
  tmp = content.match(/Source:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var source = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
  tmp = content.match(/Other:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var other = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
  tmp = content.match(/Optout:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var optout = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
  tmp = content.match(/Share:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var share = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
  tmp = content.match(/Question:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@./\s\-]+)(\r?\n)/);
    var question = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
    tmp = content.match(/E-mail:\s*([A-Za-z0-9!"?`?|õüö’çëÅíšÃÉÁÇÃáéñãóú#&amp;;()-,'@_.\-]+)/);
    var email = (tmp &amp;&amp; tmp[1]) ? tmp[1].trim() : 'BLANK';
  
    tmp = content.match(/BLANK:\s*([\s\S]+)/);
    var blank = (tmp &amp;&amp; tmp[1]) ? tmp[1] : 'BLANK';
  
    sheet.appendRow([first, last, title, organization, city, state, country, email, affiliation, source, other, optout, share, question]);
  
  } // End if
  } // End for loop
  }
  </code></pre>