We've learned about capturing groups: Now what about when we want to use parenthesis as visual helpers for when humans read our regexs and not capture anything with them? Luckily, we can turn our capturing groups into non-capturing groups for just this reason. Non-capturing groups allow us to use grouping without that group being counted towards any of our numerical backreferences. To demonstrate this, we further refactor our table of contents one-liner, switching from
sed to Perl to print out our captured heading, all while ignoring the matched HTML tags.
Get the lesson files here!: