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