title: Google Spreadsheet Script RegEx on Range of Cells
body: <p><strong>Background (Optional)</strong>: I wrote a working script in VBA that I'm trying to write in JS for Google Spreadsheets, but I'm having a tremendous amount of difficulty with the regex validation on a per cell basis.</p>
  
  <p>In this VBA code snippet, I set a range of data, and test each cell against a RegEx that is previously defined.</p>
  
  <pre><code>Set rRange = Range(arrLetters1(i) &amp; intRange1, arrLetters2(i) &amp; intRange2)
  
  For Each rCell In rRange.Cells
    If re.Test(rCell) Then
      rCell.Interior.Color = RGB(0, 250, 0)
    Else
      Cells((intRange1 - 1), rCell.Column).Interior.Color = RGB(250, 0, 0)
      rCell.Interior.Color = RGB(250, 0, 0)
    End If
  Next rCell
  </code></pre>
  
  <hr>
  
  <p>What I'm curious about, is the actual <strong>JavaScript</strong> function that would allow me to look through the same range and perform the same operation.  Here's what I have:</p>
  
  <pre><code>var re = "[a-z]+"
  var rRange = sheet.getRange(arrLetters1(i) + intRange1, arrLetters2(i) + intRange2)
  
  for (var rCell in rRange) {
    if (rCell //is a "re" match) {
        //do some code
    }
  } else {
       //do something else
  }
  </code></pre>