in reply to Re^6: Date format
in thread Date format

the issue is/ :, the leading zero in the time is also need to be removed.

So why not account for that? You could use a negative lookbehind as in this SSCCE:

use strict; use warnings; use Test::More tests => 1; my $datetime = '01/08/2018 05:58'; my $want = '1/8/2018 5:58'; my $have = $datetime; $have =~ s/(?<![:\d])0//g; is ($have, $want);

If you use <code> tags in your post your code will render better too.