see what's wrong here: ereg('(^[0-1231]$).jpg$',$file_name) [] meens a group of characters, so in your case 0,1,2 and 3 are valid characters. you haven't defined any modifer like ?,*,+ or{}, so one of this characters has to be found exactly one time. you're using ^ outside the [] so it meens the beginning of the string. in your case none of these characters inside the [] can be found at the beginning of the string. then you use $ after the []. $ meens the end of the string. none of the characters in the [] matches at the end of the string. so this would be right:
ereg('_[0-9]{4}\.jpg$', $file_name); so this meens: the beginning of the string doesn't matter, because we have not specified ^ at the beginning. there has to be an underscore, followed by 4 characters between 0 and 9, followed by an dot, followed by j, followd by p, followed by g. g has to be at the end of the string, because of the $. or you can use: ereg('^\.*_[0-9]{4}\.jpg$', $file_name); this will meen : any characters at the beginning between 0 and unlimited times, then followed by an underscore, followed by 4 characters between 0 and 9, followed by a dot, followed by jpg. same as above though. But the * is a real performance eater so it could be slightly faster if you're using the first example. "Jas" <[EMAIL PROTECTED]> schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I hate to say it but that didn't work, I have been trying different > variations of the same ereg('_(^90-9{4}$).jpg$',$file_names) and nothing > seems to work for me, I have also been looking at the ereg and preg_ereg > functions but they don't seem to make sense to me, here is the code as a > whole if this helps: > // query directory and place results in select box > $dir_name = "/path/to/images/directory/on/server/"; // path to directory on > server > $dir = opendir($dir_name); // open the directory in question > $file_lost .= "<p><FORM METHOD=\"post\" ACTION=\"done.php3\" NAME=\"ad01\"> > <SELECT NAME=\"image_path\">"; > while ($file_names = readdir($dir)) { > if ($file_names != "." && $file_names !=".." && ereg('_(^[0-9]{4}.jpg$)', > $file_names)) // filter my contents > { > $file_lost .= "<OPTION VALUE=\"$file_names\" > NAME=\"$file_names\">$file_names</OPTION>"; > } > } > $file_lost .= "</SELECT><br><br><INPUT TYPE=\"submit\" NAME=\"submit\" > VALUE=\"select\"></FORM></p>"; > closedir($dir); > What I am trying to accomplish is to list the contents of a directory in > select box but I want to filter out any files that dont meet this criteria > *_4444.jpg and nothing is working for me, any help or good tutorials on > strings would be great. > Jas > "Erik Price" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > On Thursday, April 11, 2002, at 05:59 AM, jas wrote: > > > > > Is this a correct string to show only files that look like so: > > > *_2222.jpg > > > if ($file_names != "." && $file_names !=".." && > > > ereg('(^[0-1231]$).jpg$',$file_name)) > > > Any help would be great. > > > > preg_match(/^_[0-9]{4,4}\.jpg$/, $file_name) should match any string > > that starts with an underscore, is followed by exactly four digits, and > > then a ".jpg". It will not match anything but this exact string. > > > > > > Erik > > > > > > > > > > ---- > > > > Erik Price > > Web Developer Temp > > Media Lab, H.H. Brown > > [EMAIL PROTECTED] > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php