Regular Expressions 101

Community Patterns

File filtering by extension

2

Regular Expression
PCRE (PHP <7.3)

/
([a-z A-Z 0-9 À-ÿ]*).(?i)(\bpb\b|\bpbi\b)
/

Description

You would like to scan a folder containing many files (Example : *.pb, *.pbi, *.pbp and *.pbf) and you are interested only by two type of files (example : *.pb and *.pbi). This expression will match only if extension match (in this case *.pb and *.pbi) otherwise no reaction. Feel free to change file extensions has need.

Submitted by StarBootics - 9 years ago