Search notes:

Regular expressions: Multi line mode

When multi line mode is enabled in a regular expression, the two special characters ^ and $ not only match at the beginning or end of the input text, but also right before or after a new line.
Within a regular expression, multi line mode can be enabled with (?m)… (Perl regexp flavor).
The following PowerShell example tries to demonstrate the difference between default and multi-line mode:
By default, $ does only match at the end of the input string;
PS C:\> "one`ntwo`nthree" -replace '$', ' EOL'
one
two
three EOL
However, with mutli line mode, all «end of lines» are replaced;
PS C:\> "one`ntwo`nthree" -replace '(?m)$', ' EOL'
one EOL
two EOL
three EOL

See also

With single line mode (which is not mutually exclusive to multi line mode), a dot . matches any character, including a new line.
Regular expressions.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758199316, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/regular-expressions/modes/multi-line/index(59): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78