This reduces the degrees of freedom of the ^ $ . operatorsMaybe that hints at the following inconsistency I see with the "the end of the line (or before newline at the end)" rule?
Example
Gives:print('String: a\nb\nc\n' . "\n"); $text_1 = "a\nb\nc\n"; $text_1 =~ s@(\n)$@@s; print("----------\n>" . $1 . "<\n"); print("----------\n>" . $text_1 . "<\n");
In this case, the $ behaved like \z. Or another way to say it, in this case explicit \n matches where dot with s mod doesn't.String: a\nb\nc\n ---------- > < ---------- >a b c<
In reply to Re^2: How to match last character of string, even if it happens to be a newline?
by Allasso
in thread How to match last character of string, even if it happens to be a newline?
by Allasso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |