โจmatchAll() using named groups
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
JS โฉ primitives โฉ String โฉ methods โฉ .matchAll() โฉ using named groups
๐พ ็จๅผ๏ผreplit
// โญ๏ธ pattern: yyyy-mm-dd (โญ๏ธ using "named groups")
// โญ--- year ---โฎ โญ--- month ---โฎ โญ--- day ---โฎ
let date = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g;
// text
let str = "2019-10-30, 2020-01-01, 18:24:00";
// โญ๏ธโญ๏ธโญ๏ธ result of `str.matchAll()` is an "iterable", NOT an arrayโ๏ธ