Reputation: 41
Hello I'm new with PowerShell. I have a string that I'm trying to add an "-" between every third char.
00255D413701 -> 00-25-5D-41-37-01
Anyone has an idea how to do this the easiest way?
Upvotes: 0
Views: 231
Reputation: 60518
(?<=\G.{2})(?!$)
might do the trick using regex and -replace
:
'00255D413701' -replace '(?<=\G.{2})(?!$)', '-'
See https://regex101.com/r/MWOSie/1 for details.
Upvotes: 1