<p>Regular expressions with lots of groups and backreferencing can be difficult to maintain, as adding or removing a capturing group in the middle of the regex turns to change the numbers of all the groups that follow the added or removed group.</p>
<p>In regex, we have facility of named groups, which solves the above issue. Let's look at it.</p>
<p>We can name a group by putting <code>?<name></code> just after opening the paranthesis representing a group. For example, <code>(?<year>\d{4})</code> is a named group.</p>
<p>Below is a code, we have already looked in <strong>capturing groups</strong> part. You can see, the code is more readable now.</p>
<p>Backreference syntax for numbered groups works for named capture groups as well. <code>\k<name></code> matches the string that was previously matched by the named capture group <code>name</code>, which is a standard way to backreference named group.</p>