<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bonnie DiPasquale</title>
    <description>The latest articles on DEV Community by Bonnie DiPasquale (@bvasko).</description>
    <link>https://dev.to/bvasko</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F794349%2F12d8da66-11e5-4f1a-bd5b-7ffcad37b2c7.jpeg</url>
      <title>DEV Community: Bonnie DiPasquale</title>
      <link>https://dev.to/bvasko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bvasko"/>
    <language>en</language>
    <item>
      <title>Regular expression named capture groups</title>
      <dc:creator>Bonnie DiPasquale</dc:creator>
      <pubDate>Sat, 15 Jan 2022 15:25:47 +0000</pubDate>
      <link>https://dev.to/bvasko/regular-expression-named-capture-groups-58cn</link>
      <guid>https://dev.to/bvasko/regular-expression-named-capture-groups-58cn</guid>
      <description>&lt;p&gt;I saw this tweet today and wanted to dig a little deeper into the destructuring assignment...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BwPn_W3u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/loiw4g9ultede9b6vo35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BwPn_W3u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/loiw4g9ultede9b6vo35.png" alt="Addy Osmani tweet on regular expression capture groups" width="880" height="1312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The capture group is composed by putting everything in the group between parens, and naming it with ?&amp;lt;name&amp;gt;&lt;/p&gt;

&lt;p&gt;so year alone would like this:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const year = /(?&amp;lt;year&amp;gt;\d{4})/&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The destructuring part of the tweet and Axel's follow-up, I found confusing. How can I destructure it as both an object and array?&lt;/p&gt;

&lt;p&gt;const [match, year, month, day] = re.exec('2021-03-04');&lt;/p&gt;

&lt;p&gt;Looking at the object keys helped clear things up:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log("'re' object keys:",Object.keys(re.exec('2021-03-04')));&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;gives me:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["0","1","2","3","index","input","groups"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Code can be found here:&lt;br&gt;
&lt;a href="https://codepen.io/bvasko/pen/NWaoXbb?editors=0011"&gt;Codepen&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
