Regular Expressions 101

Community Patterns

Invalid Windows Filename Chars

2

Regular Expression
PCRE (PHP <7.3)

/
[\x00-\x1F\x7F<>:"\/\\|?*]
/
gm

Description

https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file

Integer value zero, sometimes referred to as the ASCII NUL character.

Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.

The following reserved characters:

  • < (less than)
  • > (greater than)
  • : (colon)
  • " (double quote)
  • / (forward slash)
  • \ (backslash)
  • | (vertical bar or pipe)
  • ? (question mark)
  • * (asterisk)
Submitted by anonymous - 8 months ago (Last modified 8 months ago)