title: How to detect if a cell value start with an apostrophe in new Google Sheets
body: <p>Assume that in a Google Sheets spreadsheet there is a fill in the blank question in cell A2:</p>
  
  <blockquote>
    <p>I ____ happy.</p>
  </blockquote>
  
  <p>The answer should be written in cell B2. The correct answers are</p>
  
  <ul>
  <li>'m</li>
  <li>am</li>
  </ul>
  
  <p>Examples of wrong answers:</p>
  
  <ul>
  <li>m</li>
  <li>a</li>
  <li>is</li>
  <li>are</li>
  <li>be</li>
  </ul>
  
  <p>The test formula in C2 is <code>=REGEXMATCH(B2;"^['a]m$")</code>.</p>
  
  <p>The problem is that when B2 value is <code>'m</code> the above formula returns <code>FALSE</code> instead of <code>TRUE</code>.</p>
  
  <p>By the other hand, by using a Google Apps Script function to check the cell value, getValue() returns <code>m</code> instead of <code>'m</code>.</p>
  
  <pre><code>function check(){
    var file = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = file.getSheetByName('Hoja 1');
    var range = sheet.getRange('B2');
    var value = range.getValue();
    throw value;  
  }
  </code></pre>
  
  <p><hr>
  UPDATE:<br>
  <a href="https://stackoverflow.com/a/15992619/1595451">https://stackoverflow.com/a/15992619/1595451</a> and <a href="https://stackoverflow.com/a/16698417/1595451">https://stackoverflow.com/a/16698417/1595451</a> are answers for questions relaed to the opposite problem, removing the leading apostrophes. They use <code>substring(1)</code> to remove the apostrophes. At this time, when the value is <code>'m</code> it return an empty string (<code>""</code>).</p>
  
  <p><hr>
  Attribution: The original question was posted in the Google Drive Help forum in Spanish by Salvador Pérez Gómez. <a href="https://productforums.google.com/forum/#!topic/docs-es/sVg3PO8EkTk" rel="nofollow noreferrer">Reconocer expresiones que comienzan por apóstrofe o comilla simple ( ' )</a>.</p>