How the Substitution of the 3rd to the last occurrence using SED command works? : <p>Let's consider the 'file.txt',
<a href="https://i.stack.imgur.com/qt4sr.png" rel="nofollow noreferrer">click for the file contents</a></p>

<p>I want to substitute the 3rd to the last occurrence of "p".</p>

<pre><code>sed -E 's/(.*)p((.*p){2})/\1@\2/' file.txt
</code></pre>

<p>Here, "p" is substituted by "@".
I want to know how it works.
Can anyone explain me ? </p>
