Regular Expressions 101

Community Patterns

Validate a Particular File Extension

4

Regular Expression
PCRE (PHP <7.3)

/
(?i:^.*\.(xls|xlsx|doc|docx)$)
/

Description

Validates a File Path and makes sure the correct extension is at the end.

Submitted by Andrew Morpurgo - 9 years ago