Results 1 to 5 of 5

Thread: Regular expression help with image extensions

  1. #1
    Join Date
    Aug 2006
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Regular expression help with image extensions

    (! 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?

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    preg_match( "/^<img src=(.*)(.png|.jpg|.gif)/i", $show )
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  3. #3
    Join Date
    Aug 2006
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks but shouldnt i break the dots for the extensions?

  4. #4
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    if you mean escape, then yes.here it is escaped
    Code:
    preg_match( "/^<img src=(.*)(\.png|\.jpg|\.gif)/i", $show )
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  5. #5
    Join Date
    Aug 2006
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •