PDA

View Full Version : Regular expression help with image extensions



chas
05-31-2008, 08:19 PM
(! preg_match( "/^<img src/i", $show ) )

hi there i need to select all images with extension .png|.jpg|.gif

How do i alter the above RE to exclude images?

Master_script_maker
06-01-2008, 01:20 PM
preg_match( "/^<img src=(.*)(.png|.jpg|.gif)/i", $show )

chas
06-01-2008, 01:57 PM
thanks but shouldnt i break the dots for the extensions?

Master_script_maker
06-02-2008, 02:17 AM
if you mean escape, then yes.here it is escaped
preg_match( "/^<img src=(.*)(\.png|\.jpg|\.gif)/i", $show )

chas
06-02-2008, 06:17 AM
preg_match( "/\.(png|jpg|gif)/i", $show )


would this work???

1. i just need to detect the extension without the src part

2. and would it be faster to have the dot outside the extention part??

thanks again