I am trying to keep content in a file that matches the file name. It is working but I have problems with cases and I cannot do what I usually do : make everything in lowercases since the File name should not be changed. For example filename is "iPhone X" and in the cells I will have values like "iPhone X", "IPHONE X", "iphone X" and even with a space after like "iPhone X "
Is there any way to do that ?
Here is my code
//Only keep data that contains the file name
var name = spreadsheet.getName();
let range = sheet.getDataRange(),
maxRows = sheet.getMaxRows(),
srchCol_1 = 2,
srchPatt_1 = new RegExp(name)
newRangeVals = range.getValues().filter(r => r[0] && srchPatt_1.exec(r[srchCol_1])),
numRows = newRangeVals.length;
range.clearContent();
sheet.getRange(2,1, numRows, newRangeVals[0].length).setValues(newRangeVals);
sheet.deleteRows(numRows + 1, maxRows - numRows);

