User Tools

Site Tools


regex:file_types

Regex - File Types

^.*\.(jpg|JPG|gif|GIF|doc|DOC|pdf|PDF)$

^.+\.(?:(?:[dD][oO][cC][xX]?)|(?:[pP][dD][fF]))$

NOTE: This will accept .doc, .docx, .pdf files having a filename of at least one character:

  • ^ - beginning of string.
  • .+ - at least one character (any character).
  • \. - dot ('.').
  • (?:pattern) - match the pattern without storing the match).
  • [dD] - any character in the set ('d' or 'D').
  • [xX]? - any character in the set or none.
    • x may be missing so 'doc' or 'docx' are both accepted.
  • | - either the previous or the next pattern.
  • $ - end of matched string.

WARNING: Without enclosing the whole chain of extensions in (?:), an extension like .docpdf would pass.


regex/file_types.txt · Last modified: 2025/05/27 07:34 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki