Regular Expressions 101

Community Patterns

Trim part of filename to limit length

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^([0-9_. ]+)([А-Яа-я\- ]{1,80}).*?(_.*)
/
gm

Description

Truncate the middle block in the filename if it exceeds the maximum length and leave constant blocks at the beginning and end

Submitted by Andrey Smirnov - a year ago