Find and replace multiple attributes from img tag using PHP RegEx
<pre><code>//Example of image
$image = '&lt;img src="../img/image.jpeg" title="Title" alt="Alt"/&gt;';
</code></pre>

<p>I have all this $patterns where i can take the value one at a time</p>

<pre><code>// get the src for that image
$pattern_src = '/src="([^"]*)"/';

// get the title for that image
$pattern_title = '/title="([^"]*)"/';

// get the alt for that image
$pattern_alt = '/alt="([^"]*)"/';
</code></pre>

<p>How can i use <strong>all</strong> this $patterns with <strong>preg_replace</strong> like this:</p>

<pre><code>preg_replace($pattern_src+$pattern_title+$pattern_alt,$1$2$3,$image);
</code></pre>

<p>Values</p>

<pre><code>$1 =&gt; src value
$2 =&gt; title value
$3 =&gt; alt value;
</code></pre>

<p>Why i need it</p>

<pre><code>&lt;figure&gt;
    &lt;figcaption&gt;
    $2 //Title value
    &lt;/figcaption&gt;
    &lt;img src="../web/img/$1"&gt; //New src 
    &lt;figcaption&gt;
    $3 //Alt value
    &lt;/figcaption&gt;
&lt;/figure&gt;
</code></pre>