Advertisement
bebo231312312321

Untitled

Mar 16th, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function matchDates(arr){
  2.     let pattern = /(?<day>\d{2})([\/.-])(?<month>[A-Z][a-z]{2})\2(?<year>\d{4})/g;
  3.     let validDates = [];      //arr[0].match(pattern);
  4.     let text = arr[0];
  5.  
  6.     // let test = pattern.test(text);
  7.     // console.log(test) //false
  8.  
  9.     while((validDates = pattern.exec(text)) !== null){
  10.         let day = validDates.groups['day'];
  11.         let month = validDates.groups['month'];
  12.         let year = validDates.groups['year'];
  13.         console.log(`Day: ${day}, Month: ${month}, Year: ${year}`);
  14.     }
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement