I am using this code
substr(trim($val), 0, 2).'/'.substr(trim($val), 0, 4).'/'.trim($val);
to convert
a.b.c.
to
a. / a.b. / a.b.c.
This obviously does not work as soon as I get double digits like a.bb.c., which results in
a. / a.bb / a.bb.c.
(dot is missing!) instead of
a. / a.bb. / a.bb.c.
Is there a way to extract/trim parts not based on length, but on the dots?