PowerShell examples
By default $
matches at the end of a string, but not before a new line;
PS C:\> "one`ntwo`nthree" -replace '$', ' EOT'
one
two
three EOT
With multi line mode, $
also matches before an end of line:
PS C:\> "one`ntwo`nthree" -replace '(?m)$', ' EOL'
one EOL
two EOL
three EOL
It should be noted that the
.NET regular expression engine only considers
\n
(0x0a) to be a new line, but not
\r\n
(
0x0d 0x0a
).
PS C:\> "foo`nbar" -match '(?m)o$'
True
PS C:\> "foo`r`nbar" -match '(?m)o$'
False