fork(2) download
  1. <?php
  2.  
  3. $string = "<img class=\"img-responsive\" src=\"http://localhost/example-local/sites/example/files/styles/thumbnail/public/news-story/gallery-images/Desert.jpg?itok=bqyr-vpK\" width=\"100\" height=\"75\" alt=\"\" /><blockquote class=\"image-field-caption\">\r\n <p>Desert</p>\n</blockquote>\r\n";
  4.  
  5. preg_match('~src=\\"(.*?)\\"~i', $string, $matches);
  6. print $matches[1];
  7.  
  8. print "\n\n";
  9.  
  10. print preg_replace('~.*?src=\\"(.*?)\\".*~is', '$1', $string);
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
http://localhost/example-local/sites/example/files/styles/thumbnail/public/news-story/gallery-images/Desert.jpg?itok=bqyr-vpK

http://localhost/example-local/sites/example/files/styles/thumbnail/public/news-story/gallery-images/Desert.jpg?itok=bqyr-vpK