in reply to Re: How to match last character of string, even if it happens to be a newline?
in thread How to match last character of string, even if it happens to be a newline?
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<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to match last character of string, even if it happens to be a newline?
by AnomalousMonk (Archbishop) on May 12, 2019 at 16:56 UTC |