Q:

How to use sed to replace the first column (unknown floating point) of a given row, then pad with spaces to nth character

I have a file that I wish to edit with sed (or awk or similar) via a script.  
Example file contents:
    362.4318             str1                 uag tj
-19.275620800            string2 (blah)       uag tt
367.                     randomtext           uag tu
 0.05699651698647584     blab*blah(something) uag tv
    .008306              la*la(word)          uag tw
  54                     la*la(word)          uag tx

I have an associative array that contains the row number to be edited, and another that contains the new value to be inserted.  I can mostly do the replacement with the following command (though this fails for row 6 in the example since there is no decimal): 
 sed  -i ''${rowArray[$key]}'s/.*\.[0-9]*/'${valueArray[$key]}'/'  $file

Also, The unaltered part of the string (2nd column and beyond) should always start at the 26th character (or later if the new value requires more than 24 characters), even if it was originally to the left of the 26th character.  I've read a bit about padding, but I don't understand the syntax.  
Any advice is greatly appreciated!

A:

You can use this:
sed -i -r "${rowArray[$key]}s|^\s*-?[0-9.]+|${valueArray[$key]}|" file

Or
sed -i "${rowArray[$key]}s|^[[:blank:]]*-\?[0-9.]\+|${valueArray[$key]}|" file

0-9 can also be [:digit:]
[:blank:] can also be just <space>\t.

Update
printf -v paddedValue '%24s ' "${valueArray[$key]}"
sed -i -r "${rowArray[$key]}s|^\s*-?[0-9.]+\s*|$paddedValue|" file

