How to format numbers using Regular Expression in PHP

I would need to change the format to 123.456.789.11, so far I have only managed to do it as shown in the example https://regex101.com/r/sY1nH4/1, but I would need it to always have 3 digits at the beginning, thank you for your help

$repl = preg_replace('/(?!^)(?=(?:d{3})+$)/m', '.', $input);