my $line = "3434 34456... 321ms:543ms:45ms"; if ( $line =~ m/(\d+)\D+(\d+)\D+(\d+)\D+$/ ) { print( "$1,$2,$3\n" ); }