Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
(\"(?P<filename>[\p{L}\d\s\[\]_,.\-\(\)\+]+\.(?P<extension>\w{1,5}))\"(?!.*\"([\p{L}\d\s\.\[\]_,.\-\(\)\+]+\.\w{1,5})\"))
/

Description

When a string contains two or more possible filenames in quotes grab the last one and return it as <filename> and <extension>

Submitted by warlord - 9 years ago