$str1='<a href="/bla/string">string</a>'
$str2=$1str -replace '<[^>]+>',''
$str3=$1str.replace('<[^>]+>','')
$str2='string'
$str3='string'
$str2='string'
$str3='<a href="/bla/string">string</a>'
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.2430
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.2430
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
@B-Art [string].Replace() just does simple string replacement. The -replace operator uses regular expressions like [regex]::replace().
If any more clarity is required...
.Replace() is a string method build into the [string] data type by the .NET designers.-replace is a string operator implemented by the PowerShell team utilising the [RegEx]::Replace() .NET method behind the scenes in order to give additional, easy to access functionality to PowerShell itself. Thanks for all your answers!
Most helpful comment
If any more clarity is required...
.Replace()is a string method build into the[string]data type by the .NET designers.-replaceis a string operator implemented by the PowerShell team utilising the[RegEx]::Replace().NET method behind the scenes in order to give additional, easy to access functionality to PowerShell itself.