JavaScript Regex Named Extract

November 3, 2021
const regex = /'(?<year>\d{4})','(?<month>\d+)','(?<day>\d+)'/
const text = "('2001','1','30')"

const m = regex.exec(date)
if (m) {
  const date = `${m.groups.year}-${m.groups.month}-${m.groups.day}`
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.