Extraction of rows containing specific strings in Google Apps Script (GAS)

Asked 1 years ago, Updated 1 years ago, 39 views

I'm creating a code that only takes out certain strings in the first column of the spreadsheet, but it doesn't work.
I would appreciate it if you could point it out.

function myFunction(){
  const sheet = SpreadsheetApp.getActiveSheet();
  constlastRow=sheet.getLastRow();
  for(leti=2;i<=lastRow;i++){
    var str = sheet.getRange(i,1).getValue();
    console.log(str.match(/{regular expression for specific characters}/g));
  }
}

google-apps-script

2022-09-30 17:39

1 Answers

The regular expression seems to have been incorrect, so I changed it to "+" → ".*" in the regular expression category and it worked.


2022-09-30 17:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.