having difficulty with regex replacing multiple lines in a variable

why does this script remove multiple lines

str =
@"
123
abc
456
xyz
789
"@
$str -replace "(?ms).*45",""

and output this as expected

6
xyz
789

but this script removes only the beginning of many lines

`$str = schtasks /query /fo csv`
`$str -replace “(?ms).\.\”,""`

Could you please use the code tag button (pre) for your code next time? Thanks.

In your first case there’s one single string with line breaks (a so called “here string”) and the second case is about multiple strings (an array of strings) … like this …

$str = @(
'123'
'abc'
'456'
'xyz'
'789'
)
$str -replace "(?ms).*45", ""

… a kind of

sorry for the faux pas. I mistakingly thought format->code was the right way to format code