in reply to regular expression
This seems to do the trick:
>perl -wMstrict -le "my $s = '~/tmp/hfj/abc/bhd/5009.xmlreal.xml'; $s =~ s{ \A .* / \d+ }{}xms; print qq{'$s'}; " '.xmlreal.xml' [download]