Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
\\(?=[^\\]*(?=\\(?=[^\\]*(?=\.(?![^\\]*(?=\\))))))(.*)(\..*)
/
gm

Description

This expr will get the parent folder and file name from a full path eg: c:\folder1\folder2\folder3\file1.txt returns folder3\file1.txt

Submitted by anonymous - 5 years ago