JSFiddle - React, Tailwind, and code Playground

JavaScript

function zeroFill( number, width ){
  if ( number.toString().length >= width )
    return number;
  return ( new Array( width ).join( '0' ) + number.toString() ).substr( -width );
}

alert(
"abc8 23 123".replace(/\d+/g,function(x){ return zeroFill(parseInt(x),6) })
    )