z_abcd0123.jpg - name of the picture

Need check template for preg_match ()

Conditions:

where z - characters az long 1 character,

where abcd0123 is the characters af, 0-9 are 8 characters long,

jpg - characters az up to 5 characters long

Practices, of course, do not work:

preg_match("[az]{1}\_[a-f0-9]{8}\.[az]{,5}",$img) 

    3 answers 3

    You were very close)

     preg_match("/[az]{1}\_[a-f0-9]{8}\.[az]{3,5}/", $img); 

    You can still $img through strtolower drive.

       [az]{1}\_[a-f0-9]{8}\.[az]{3,5} 

      PS vkontaktik?

      • almost ... just by the same mechanism I will give the names of the pictures - oxyage

      If it is quite simple (quickly, but not so selectively), then:

       /\w{10}\.\w{,5}/ или /\w{10}\.\w{0,5}/ 

      If you add the same conditions:

       /[az]\_[af\d]{8}\.[az]{,5}/ или /[az]\_[af\d]{8}\.[az]{0,5}/ 

      BUT:

      1. File extension may contain numbers - at least the same mp3
      2. File can be without extension

      Therefore, IMHO: Solve a specific problem! As I understand it - a photo from the contact:

       /[az]\_[az\d]{8}\.jpg/ 
      • The question is put - the answer is there, and it suits me 1. I don’t know pictures with the mp3 extension 2. The file cannot be without an extension, because when the file is loaded it is given a random name and at the end, the extension is oxyage
      • one
        JPEG-2000 has the extension .jp2 - timka_s
      • Well, these are some transcendental formats that did not figure in the conditions of the question, which means I don’t need them. But thanks, googled - oxyage