in reply to remove chars with regex
An alternative to using a regex is substr applied at either end of the string.
johngg@aleatico:~$ perl -Mstrict -Mwarnings -E 'say q{}; my $char = q{0x388c818ca8b9251b393131c08a736a67ccb19297}; say join q{ ... }, substr( $char, 0, 6 ), substr( $char, length( $char ) - 6, 6 );' 0x388c ... b19297
I hope this is helpful.
Update: Re. AnonyMonk's comment regarding negative offsets, I had completely forgotten that, how dumb am I :-(
Update 2: Here's the amended code.
johngg@aleatico:~$ perl -Mstrict -Mwarnings -E 'say q{}; my $char = q{0x388c818ca8b9251b393131c08a736a67ccb19297}; say join q{ ... }, substr( $char, 0, 6 ), substr( $char, -6 );' 0x388c ... b19297
Cheers,
JohnGG
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: remove chars with regex
by Anonymous Monk on Feb 26, 2025 at 15:32 UTC |