Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(.+)_[[:digit:]]+(\..+)$
/
gm

Description

When in Drupal you upload a file with the same filename a new file name is created with <original-filename>_<number>.<extension>. The regexp is made to filter the supposedly original filename. After checking existence and filelength match the presuppostion is confirmed and deduplication takes place.

Submitted by anonymous - 4 years ago