in reply to Re: remove chars with regex
in thread remove chars with regex

I think that would return the middle part but not result in "(5 chars) ... (5 chars)". More like
$ perl -Mstrict -wE'my $char = "0x388c818ca8b9251b398a736a67ccb19297"; substr($char, 5, -5, " ... "); say $char' 0x388 ... 19297
(assuming the string is long enough)

Replies are listed 'Best First'.
Re^3: remove chars with regex
by ikegami (Patriarch) on Feb 27, 2025 at 11:18 UTC

    To remove the middle instead of keeping the middle, you could use

    substr( $char, 5, -5, "" ); # In-place
    or
    my $output = substr( $char, 0, 5 ) . substr( $char, -5 );