php preg_match_all backslash problem
<p>I've got img tag in my text and I want to get the name of the file from src</p>

<p>So I use this code </p>

<pre><code>preg_match_all("|\/img\/(.*)\/&gt;|U", $article_header, $matches, PREG_PATTERN_ORDER);
echo "match=".$matches[1][0]."&lt;br/&gt;";
</code></pre>

<p>Doing so I get this as a result</p>

<p><strong>match=500.JPG\" alt=\"\" width=\"500\" height=\"360\"</strong> </p>

<p>So in this case I use "\/>" which means the end of tag.</p>

<p>But I want only name of the file "500.JPG" So I must use "\" but when I do it</p>

<pre><code>    preg_match_all("|\/img\/(.*)\\|U", $article_header, $matches, PREG_PATTERN_ORDER);
</code></pre>

<p>I get no matches :(
Please help</p>

<p>With the help of yes123 I did this</p>

<pre><code>$doc = new DOMDocument();
$doc-&gt;loadHTML($article_header);

$imgs = $doc-&gt;getElementsByTagName('img');
$img_src = array();
foreach ($imgs as $img) {
// Store the img src
$img_src[] = $img-&gt;getAttribute('src');
echo $img_src[0];
}
</code></pre>

<p>which gives me this</p>

<p><strong>\"sources/public/users/qqqqqq/articles/2011-06-11/7/img/500.JPG\"</strong></p>

<p>But now anyway I want only 500.JPG from this</p>

<p>So what is the right regexp ?</p>
