Removing special characters from a string
geeks, i'm in need of logic need remove " string
"\\winshare\a\b\c\d.csv"
would need as-
\\winshare\a\b\c\d.csvkindly suggest me way this.
cheers, alan.
checking existence has nothing using substrings. that's still avoided if can.
$str = '"\\winshare\a\b\c\d.csv"' if ($str.contains('"')) { $str = $str.replace('"','') } $str
edit: here's example of why.
$str = '\\winshare\a\b\c\d.csv"' $str2 = '"\\winshare\a\b\c\d.csv' write-host 'bad' -foregroundcolor red $str.substring(1,$str.lastindexof('"')) $str2.substring(1,$str2.lastindexof('"')) write-host 'good' -foregroundcolor green $str.replace('"','') $str2.replace('"','')
Windows Server > Windows PowerShell
Comments
Post a Comment