Google 脚本 getCalendarsByName 到 return 具有相似名称的日历

Google Scripts getCalendarsByName to return calendars with similar names

我想执行一项功能,允许我仅查询 google 具有特定字符(即“#”)的日历。

我知道函数 CalendarApp.getCalendarsByName return 是一个日历数组,所以我希望我可以将此函数与通配符一起用于 return 我想要的日历。我从这里 https://productforums.google.com/forum/#!topic/calendar/gmf6ewpjH4g/

得到了一些关于使用通配符的建议

目前的代码如下:

function Test() {  
  var pattern = /.*#.*/;
  var calendarsz = CalendarApp.getCalendarsByName(pattern); 
  Logger.log('Found %s matching calendars.', calendarsz.length);
};

但它 return 根本没有日历。任何有关如何将通配符与此功能一起使用的建议,或 return 仅具有特定字符的日历的替代方法将不胜感激。

getCalendarsByName方法不支持通配符搜索

getCalendarsByName(name)

Gets all calendars with a given name that the user owns or is subscribed to. Names are not case-sensitive.

// Gets the public calendar named "US Holidays".
var calendars = CalendarApp.getCalendarsByName('US Holidays');
Logger.log('Found %s matching calendars.', calendars.length);

Parameters

Name - the calendar name

就此而言,Google 日历 API 也不支持它,因此它根本无法工作。你将不得不下载它们并在本地搜索它们可能使用 getAllCalendars