How to mark end of the row when using match() function? From this page I need to pull out “2021 JANUARY 18 MONDAY”
When somethng exists after desired string I’ve used this code:
JavaScript
x
4
1
var page = UrlFetchApp.fetch(link).getContentText();
2
3
var date = page.match(/results of (.*?)SOMETHING/m)[1];
4
but now I can’t
Advertisement
Answer
Here’s how that date format can be matched in a string:
JavaScript
1
4
1
var string = "lorem ipsum 2021 January 18 Monday";
2
var date = string.match(/(d{4} [A-z]+ d{1,2} [A-z]+)/)[0] || null;
3
4
console.log(date);