Regular Expressions 101

Community Patterns

Detect Multiple File Extensions

1

Regular Expression
PCRE (PHP <7.3)

/
^([\w.]{1,})\.([\w]{3,4})\.([\w]{3,4})$
/
gm

Description

I use this to find files with two or more extensions (i.e. file.txt.txt). This will work with files with 3 or 4 character or numeric (or both) file extensions (i.e. pdf, xlsx).

Submitted by Curve - 2 months ago (Last modified 2 months ago)