Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?(DEFINE)(?'dn'[^\\\/:*"<>|\ ]+[^\\\/:*"<>|]*[^\\\/:*"<>|\.\ ]+)(?'ds'\\|\/))(?'fn_path'(?'f_path'(?&ds)?((\.{1,2}(?&ds))|((?&dn)(?&ds)))*)?(?'fn'(?&dn)))(?'ext_dot'\.(?'ext'asm))$
/
gm

Description

Parse a filename into path, filename and extension (directory names are windows style, but changeable). Matches are accessible by name and number. This is dependent on PCRE compatibility. It uses (DEFINE) non-consuming group definitions and back references. The only good description of using this feature is found at;

https://www.rexegg.com/regex-capture.html#define

Submitted by anonymous - 4 years ago