How to get the Hello "Newline" and World in powershell using regex? -
how hello “newline” , world in powershell using regex?
hello world
i have hello world text file. i'm using powershell.
this should work
$match = get-content -path <path_to_file> | out-string | select-string "hello`r`nworld" if ( $match ) { write-host $match.matches[0].groups[0].value }
we load file get-content
flatten array single string, in case piping out-string
. finally, regex applied embedded crlf.
if have powershell 3, believe can use get-content -raw
(which returns single string) , pipe straight select-string
.
my test file:
line1 hello world line4
output:
hello world
Comments
Post a Comment