JSFiddle - React, Tailwind, and code Playground

JavaScript

function process( input ) {
    var index = input.indexOf( '.' );
    
    if ( index ) {
        input = input.substr( 0, index + 1 ) + input.slice( index ).replace( /\./g, '' );
    }

    return input;
}

document.write( process( '1.2.3.4.5' ) );