in reply to How to match last character of string, even if it happens to be a newline?
You don't really need a regular expression just to get the last character in a string:
$ perl -e'use Data::Dumper; $Data::Dumper::Useqq = 1; my $text_1 = "a\ +nb\nc\n"; print Dumper $text_1, "Last character: " . substr $text_1, +-1' $VAR1 = "a\nb\nc\n"; $VAR2 = "Last character: \n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to match last character of string, even if it happens to be a newline?
by LanX (Saint) on May 12, 2019 at 19:03 UTC | |
|
Re^2: How to match last character of string, even if it happens to be a newline?
by Allasso (Monk) on May 12, 2019 at 20:58 UTC |