Skip to content

Instantly share code, notes, and snippets.

@mattcuk
Created April 12, 2020 15:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mattcuk/57c680eb602e851795a0df0cda8e16fb to your computer and use it in GitHub Desktop.
Azure Logic App - Inline Code - Multi Part Filter
var titles = workflowContext.actions.Filter_array_on_year.outputs.body;
var newTitles = [];
const regex = /(.*)(2019|2020|2021).*/i; // Regex for year filtering
titles.forEach(function(item) {
// Additional filter for titles containing 1080p only
if (item.title.indexOf('1080p') > -1) {
// Extract the title and year only
var titleMatch = regex.exec(item.title);
if (titleMatch!=null && titleMatch.length>0) {
var tidyTitle = titleMatch[1]+titleMatch[2];
var pubDay = item.pubdate.substr(5, 2); // Get the day number
tidyTitle = pubDay + " - " + tidyTitle;
// Simple dedupe
if (!newTitles.includes(tidyTitle)) newTitles.push(tidyTitle);
} else {
newTitles.push(item.title);
}
}
});
return newTitles;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment