SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Preg_match problem

    Hello,

    Files on directory like:

    file1_100x75.jpg
    file1_300x250.jpg

    file11_100x75.jpg
    file11_300x75.jpg

    file_file1_100x75.jpg
    file_file1_300x75.jpg

    Lets say i want to filter only file1 with _(someSize)x(someSize)(.someFileExt)

    So the result should only be

    file1_100x75.jpg
    file1_300x250.jpg

    How should the pattern should be?

    I am working on it for whole day. But couldn't handle it.

    Thank you

  2. #2
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think i made it

    PHP Code:
    $filter 'file1';

    preg_match("/^($filter)(_.*x.*)$/"$file$matches);

    echo 
    "<pre>";
    print_r($matches);
    echo 
    "</pre>"


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
  •