I have a textfile with CRFL line endings, I read the whole file with $c = Get-Content -Raw file.txt the file contains e.g.
exec Add a, b, c
exec Rem e, f, g
I try to replace it with my regex $c = $c -replace '(?m)^([ \t])(@exec@)([ \t]+)([a-zA-Z0-9_-]+)(.)$' '$1call$3$4($5)' This doesn't work and I don't know why but to get it working I need to run $c = $c -replace '(?m)^([ \t])(@exec@)([ \t]+)([a-zA-Z0-9_-]+)(.)\r\n?$' '$1call$3$4($5)' and the result is
call Add(a, b, c
)
exec Rem(e, f, g
)
with a LF after the ) bracket. I would expect to get
call Add(a, b, c)
exec Rem(e, f, g)
with CRLFs
What's wrong with PowerShell and $ and CRLF? Can anybody tell me how to get the correct results? Thanks.