Can an integer be formatted as a telephone number using Twig? Can an integer be formatted as a telephone number using Twig filters or other methods?

I have looked at the 'number_format' filter but it seems to be limited to controlling the number of decimals and how to delimited thousands.

Example; Integer variable from cms '20304050', output to HTML in twig like this: '20 30 40 50'.
Assuming that you always want to add a space after every two digits, something like this using Twig's split and join filters should work:

{% set splitArray = "20304050"|split('', 2) %}
{% set formattedString = splitArray|join(' ') %}


If you want a different format, like 203 04 050, then you could use slice:

{% set firstSeg = "20404050"|slice(0, 3) %}
{% set secondSeg = "20404050"|slice(3, 2) %}
{% set thirdSeg = "20404050"|slice(5, 3) %}

{% set formattedString = firstSeg ~ ' ' ~ secondSeg ~ ' ' ~ thirdSeg %}