DEV Community

Discussion on: Daily Challenge #46 - ???

Collapse
 
choroba profile image
E. Choroba

Perl solution:

my $str = 'a?b?c?';
say $str =~ tr/?//dr;

The tr operator works like the tr shell util. /d means non-replaced characters are deleted, /r returns the value instead of modifying the bound variable.