Replace spaces with 0's having numeric values.

What could be the regular expression with gsub function in awk to replace all numerics having spaces before to be replaced with 0s?

I don't think you could use gsub() because you don't know the size of the replacement string. Perhaps use match() , e.g...

  BEGIN {z = "000000000000000000000"}
  {
    while(match($0, / +[0-9]/))
      $0 = substr($0,1,RSTART-1) substr(z,1,RLENGTH-1) substr($0,RSTART+RLENGTH-1)
    print
  }