I would like to skip an iteration of code if, the data in a cell does not match a string – number – number format. For example, the desired format is Apple-34-56. If the array that I defined has a format such as Apple-Grape-23, or any other variation contrary to the desired format, it should skip to the next iteration.
function populateData (sheet1, sheet2) {
var dataRange = sheet1.getRange("A:A").getValues();
for (var i = 0; dataRange.length; i++) {
if (dataRange !== string-number-number) {
continue;
}
}
}
Is this the proper way to set up the condition?
2
Answers
What you are asking for is a regular expression to match your desired constraints.
I.e. if you meant "(any-length word)-(any-length number)-(any-length number)" your if statement would become:
That being said, you can even avoid the continue statement an make which are your targeted inputs even more clear:
A quick easy solution: