regex working not as expected javascript, displays wrong values

29 views Asked by At

i have string "This auction will run from Friday 28 July - Monday 7 August. It will close from 7pm (GMT) on Monday 7 August 2023. Read here for information on how our auctions end."

and im trying to get dates from this string

const str = "This auction will run from Friday 28 July - Monday 7 August. It will close from 7pm (GMT) on Monday 7 August 2023. Read here for information on how our auctions end.";
const regex = /(\d{1,2} \w+(?: \d{4})?)/g;
const dates = str.match(regex);
console.dir(dates);

this is regex that i wrote and in regex checker site((\d{1,2} \w+(?: \d{4})?)) it matches for 28 july, 7 august and 7 august 2023, but in javascript it only matches for 7 august and 7 august 2023, whats wrong?

0

There are 0 answers