regex - PHP How can I get full image url by useing preg_match_all -


for example

$string =  'aaaaaaasssssshttp://www.1.com/images/001/001/001/1.jpgddwxeaaaaaa crewcwehttp://www.2.com/images/002/002/002/2.jpgrcegcger cgwcgrewhttp://www.3.com/images/003/003/003/3.jpgcgergcer cerggewrcgrewhttp://www.4.com/images/004/004/004/4.jpgecgewrcgerwcg cerghttp://www.5.com/images/005/005/005/5.jpg'; 

i want first image full url form stiring :

"http://www.1.com/images/001/001/001/1.jpg" 

i use function not work

 if (preg_match_all('^http:\/\/\.(png|jpeg|jpg|gif|bmp)$/i', $string, $matches))   print_r ($matches[1]); 

who can me ? thank much!

i've tested following code, , works. captures jpg-urls.

$string =  'aaaaaaasssssshttp://www.1.com/images/001/001/001/1.jpgddwxeaaaaaa crewcwehttp://www.2.com/images/002/002/002/2.jpgrcegcger cgwcgrewhttp://www.3.com/images/003/003/003/3.jpgcgergcer cerggewrcgrewhttp://www.4.com/images/004/004/004/4.jpgecgewrcgerwcg cerghttp://www.5.com/images/005/005/005/5.jpg';  preg_match_all("((http|https|ftp|ftps)://?([a-za-z0-9\\\./]*.jpg))", $string, $matches);  print_r($matches[0][0]); 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -