Jump to content

railgun

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by railgun

  1. I am no expert but I have had the file types be jpeg, pjpeg and jpg on a file with the jpg extension. You might take a look at the actual file type and, at least, eliminate that.
  2. Sorry about your computer. Everyone needs to have 3 or 4 spares. Thanks again for your help. I think I have muddled through it and come up with a workable, however un-elegant solution. I'll include it for posterity. My goal was to have a filename in an exact format, but to NOT have any two non alphanumeric characters consecutive. So far the below seems to be working fine in PHP. $str = "ABC-12_e-f3.jpg"; if ((preg_match('/^[A-Z]{3}\-\d{1,2}\_[A-Za-z0-9._-]+\.jpg$/', $str)) && (!preg_match('/[._-](?=[._-])/', $str))) { print "Good Filename"; } else { print "Bad Filename"; }
  3. Thanks for the reply. I didn't realize that I had inadvertently taken the period, hyphen, and underscore out of the expression but that is the case. And the + following the {} is just inexperience. My aim is to allow the above mentioned characters as part of the filename but just to NOT allow two of them consecutively. So, with that in mind, and to try to further my regex education, when you get some spare time, tell me how in the blue blazes do you keep two consecutive periods or hyphens or underscores out of the filename?
  4. As you can tell from the expression, I am making sure that the filename of an image is in a particular format. The trouble I'm having is with the look ahead assertion and trying to make sure that a period cannot follow another period. Then, after conquering that, I will also do the same for the other allowables. preg_match('/^[A-Z]{3}+\-+\d{1,2}+\_+[a-zA-Z0-9]+\.jpg$/', $filenameString); Thanks for your expertise.
  5. I have a site that is using a form to upload potentially large text files. What are the common characters and symbols to keep out of these files so they don't get into the db. And would you use regex to police it? Thanks in advance for your expertise.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.