in reply to Re^2: Is there a way to make these two regex lines cleaner?
in thread Is there a way to make these two regex lines cleaner?
A hyphen placed at the beginning of a character class or tr/// search/replace list is also interpreted literally:
But one can argue that one is as likely to place new stuff at the start as at the end, so escaping remains wise. :)Win8 Strawberry 5.8.9.5 (32) Sun 04/17/2022 18:43:19 C:\@Work\Perl\monks >perl use strict; use warnings; my $s = '123-abc-456'; $s =~ tr/-a-z//cd; print "'$s' \n"; $s = '123-xyz-456'; $s =~ s/[^-a-z]//g; print "'$s' \n"; ^Z '-abc-' '-xyz-'
Give a man a fish: <%-{-{-{-<
|
|---|