I have a string, inside of that I have an image:
"<p><img src="http://yahoo.com/testfolder/userdata/editoruploadimages/confused 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 "http://yahoo.com/testfolder/userdata/editoruploadimages/confused
The returned string should be:
"http://yahoo.com/testfolder/userdata/editoruploadimages/confused man.jpg"
I'd catch everything inside the quotes:
preg_match_all('/src="([^"]+)"/', $questArr_str, $images);
The parts that reads ([^\s]+)
means select anything that isn't a space.
Maybe try something like:
/src="([^"]+)"/
Which is select anything that isn't a double quote.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With