You will have to parse the string and change it to what you need.
You can start with removing the opening
($number -replace '^+45|45') -replace ' '
Now you are left with the remaing 8 digits so split them and add it all back together:
'+45 {0} {1}' -f $first4,$last4
\_(ツ)_/
Some of those numbers have space(s) separating the two four-digit groups. Here's another way to accomplish the reformatting:
$x = $number -replace '(?:\+?45)?\s?(\d{4})\s?(\d{4})', '+45 $1 $2'
The first group "(?:\+45|45)?" is non-capturing, and optional. All the spaces (\s?) are also optional.
--- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)