Removing all dots from a string except the first one

Hello Powershell guru’s,
I am looking for a way to remove all dots from a string except for the first dot.
I found this: “” -replace “.(?=..)”,“”
This removes all dots except the last one, but I need to remove all dots except the first one. Any ideas?

Kind regards,


Welcome back to the forum. :wave:t4:

May I ask what the actual job is? Is it about a version number? If that’s the case you may make your life harder than necessary. :wink:

If it’s about a version string you should treat it as such.

$Version = [version]''

You can access each individual part of a version string with its name:


… and so on … and you could use this to re-join the parts in whatever way you like …

'{0}{1}.{2}.{3}' -f $Version.Major, $Version.Minor, $Version.Build, $Version.Revision

If it’s a pure string you can use -replace with the following regex:

$Version.ToString() -replace '(?<=^\d+)\.'

It removes a literal dot preceded by some digits following the start of the string.