I'm trying the following...
$string = "*abc*"
$string = $string -replace "*",""
Write-Host $string
but get the following error
Regular expression pattern is not valid: *. At C:\Scripts\Tests\testing.ps1:3 char:1 + $string = $string -replace "*","" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (*:String) [], RuntimeException + FullyQualifiedErrorId : InvalidRegularExpression
I've tried -replace
, .replace
, .trim
, but none of them are working because they are all reading it as a regular expression. I've also tried "`*"
, and it still doesn't work.
Anyone know how to make the system not to read as a regex?