'How to remove special characters in string in powershell?

I need a help, please :) I have an executable that returns a version so I call it in powershell and store the returned value

$version=./getversion.exe

Sadly the returned string contains some special formatting characters. For the version 6.0.0 I get

[38;5;7m6.0.0[0m

Is it possible to get rid of the special characters and get just the 6.0.0 string?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source