san san - 7 months ago 35
HTML Question

Regular expression to find "src" attribute of HTML "img" element in PHP

I have a string, inside of that I have an image:

"<p><img src=" man.jpg" /></p>"

I could not fetch the image URL with my regular expression. My code is:

preg_match_all("/src=([^\\s]+)/", $questArr_str, $images);

This code stops its execution when it encounters the space in the image name. It only returns

The returned string should be:
" man.jpg"

san san

Thank every one for helping me out.

I found my solution by using:

pattern = "/src=([^\\\"]+)/"