Replace substring of a string using REGEX in Notepad++
<p>I am using notepad++ and I want to create an automation in order to replace some strings.</p>

<p>In this case I am going to deal with the <code>a href</code> tag.</p>

<p>So, I will give 3 examples of some lines I have in my code :</p>

<p><strong>01</strong>) </p>

<p><code>&lt;a href="https://url.com" class="logo"&gt;&lt;img src="urlurlurlurl" alt=""&gt;&lt;/a&gt;</code></p>

<p><strong>02</strong>) </p>

<pre><code>&lt;a href="https://url.com" class="logo"&gt;&lt;img src="urlurlurlurl" alt=""&gt;
         &lt;/a&gt;
</code></pre>

<p><strong>03</strong>) </p>

<pre><code>&lt;a href="https://url.com"&gt;&lt;img src="urlurlurlurl" alt=""&gt;&lt;/a&gt;
</code></pre>

<p><strong>04</strong>) </p>

<pre><code>&lt;a href="https://url.com"&gt;link&lt;/a&gt;
</code></pre>

<p>So, if I wanted to replace the full <code>a href</code> tag above in all 4 cases, I would use this one : <code>&lt;a href(.*?)a&gt;</code></p>

<p>Now, I am trying to think of a way to replace the url within the a href tag only. </p>

<p>I tried using that : </p>

<pre><code>href="(?s)(.*?)"|href ="(?s)(.*?)"
</code></pre>

<p>and it works fine because I also take into consideration that there might be a space.</p>

<p>But now in the replace window I have to include <code>href=""</code></p>

<p><a href="https://i.stack.imgur.com/OTA6F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OTA6F.png" alt="enter image description here"></a></p>

<p>Is there a way to make it search for the <code>a href</code> tags and then replace a specific substring of it?</p>

<p>I want to know because there are cases where I have other tags that include a url and I want to replace it. But a generic replacement for all the strings that are included within quotes ("string") would not be good as I do not to replace all of them. </p>