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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -