Open EdwardZZZ opened 5 years ago
const REGEXP_DATE = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/; const { groups: { year, month, day } } = REGEXP_DATE.exec('2018-12-12'); console.log(year, month, day);
const str = 'HelloWorld'; console.log(str.replace(/(.)?([A-Z])/g, (str1, str2, str3) => { console.log(str1, str2, str3) if (str2) return `${str2}-${str3.toLowerCase()}` return str3.toLowerCase(); }));