Regular Expressions 101

Community Patterns

Match Linux File basename and pathname

0

Regular Expression
PCRE (PHP <7.3)

/
(\/.*?\/)([^\/](?:[^\/]|\\\/)+?)(?:(?<!\\)\s|$)
/

Description

Matches 2 groups - pathname and file basename, and will exclude anything on the end of the line that is not properly escaped.

Submitted by Steve Sant - 9 years ago