Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^[^\t\r\n\\\/<>:"|?*]*[^\t\r\n\\\/<>:"|?*.\s]$
/
gm

Description

Validates a Windows filename

Filename cannot contain tab, carriage return, back slash, forward slash, less than, greater than, colon, double quote, pipe, question mark or asterisk. It also cannot end with a period or space

(Non-printable characters have been ignored due to the difficulty in actually producing them)

Submitted by anonymous - 6 years ago