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.csv
kindly 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

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file