Skip to content
Advertisement

Mark end of the row when using match() javascript

How to mark end of the row when using match() function? From this page I need to pull out “2021 JANUARY 18 MONDAY”

webpage look

sourcecode

When somethng exists after desired string I’ve used this code:

var page = UrlFetchApp.fetch(link).getContentText();

var date = page.match(/results of (.*?)SOMETHING/m)[1];

but now I can’t

Advertisement

Answer

Here’s how that date format can be matched in a string:

var string = "lorem ipsum 2021 January 18 Monday";
var date = string.match(/(d{4} [A-z]+ d{1,2} [A-z]+)/)[0] || null;

console.log(date);
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement