I don't see a function.
The real, current code would help a lot.
Basically, you determine the length of the whole real string and then $repeat() a number of space characters in which you take the total position of the | and $sub() the length.
Here is a (German) thread that centers text:
Hallo
ich hab noch einmal eine Frage zur Exportfunktion
ich möchte den Namen eines Albums (%album%) automatisch mittig in einem Überschrift-Rahmen plazieren.
Die Rahmenbreite ist fest vorgegebne (z.B. 65 Zeichen)
etwa so:
================================================================================
=..................................mein Album..................................=
================================================================================
(die Punkte links und rech…
The code should be readable, though