Regular Expressions 101

Community Patterns

Match directory path

2

Regular Expression
PCRE (PHP <7.3)

~
^/?[\w-/]+$
~
gm

Description

match with or without prevailing/trailing slashes

Submitted by @zakiaziz - 8 years ago