The {
and }
are used as delimiters and do not take part of the search pattern.
\\.
is describing a dot. The dot has to be escaped (thus the backslashes) because a un-escaped dot would describe the presence of any single character. The round brackets ( ... )
define a group that can be accessed via $1
in the second preg_replace
parameter. The content of this group consists of [^./]+
, which means
a positive quantity of (defined via the +
after the set) any single character that is not (^
in the beginning of a set means not
) a dot .
or a slash /
.
The round brackets are followed by a $
which describes the end of the line.
The expression will match the file extension of the path, like .css
, while css
will be the value of the group $1
. Therefore, .css
will be replaced with .$mtime.css
where $mtime
will be the value of the php variable.