Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?P<Root>[A-Za-z]:(?:\/|\\))(?P<Relative>(?:(?:[^<>:"\/\\|?*\n])+(?:\/|\\))+)(?P<File>(?:[^<>:"\/\\|?*\n]+)(?:\.(?:png|jpg|jpeg)))$
/
gm

Description

If u want to change the file extension match, just replace : (?:png|jpg|jpeg) by anything u want. Example : (?:txt|pdf) or (?:mp3|ogg) or (?:mp4) or etc...

Submitted by Holome - 2 years ago