As per the title,
I'd like to use powershell to delete the string "(double quotation).
Current State
$s=$(get-count "c: wwork ssample.txt")
$s
$s.trim(`"`)
However, I cannot make ["] recognized.
I look forward to your kind cooperation.
powershell
If you want PowerShell to write a string containing a double quote,
'
"`"
There are methods such as .There is no backquote syntax.
In , for example:
PSC:\>$s='foobar'
PSC:\>$s
"foo bar".
US>PSC:\>$s.Trim ('"')
foobar
Reference String - Windows PowerShell|++C++;//Unidentified Flight C
Trim()
is a method of removing consecutive characters at both ends of a string, so use the Replace()
or the -replace
operator (which uses regular expressions).
PSR:\>'a"b"c"'.Replace('",')
abc
PSR:\>'a"b"c"'-replace'"', '
abc
You can also use foreach
to read multiple lines of text in Get-Contents, but you can get the same results directly using the Replace()
method or the -replace
operator.
PSR:\>$s
"aa"
bb"cc
PSR:\>$s | foreach {$_.Replace('', ')}
aa
bbcc
PSR:\>$s.Replace('', ')
aa
bbcc
© 2024 OneMinuteCode. All rights reserved.