use regex to replace all but first occurrence of a substring of blanks

前端 未结 1 1460
慢半拍i
慢半拍i 2021-01-22 20:41

The following statement runs fine:

$wb.upLinearLoad.append(\'
\' + sprintf(\"%5s%8.1f to%7.1f%8.1f%6.0f%8.0f\",sLinearSegName[i][j],fLinearPtBA[i][j],f
1条回答
  •  攒了一身酷
    2021-01-22 21:22

    Just don't do it using strings. Instead, use the jQuery/DOM manipulation. It's less prone to error and more efficient.

    $wb.upLinearLoad.append(
        $('
    ').append( sprintf("%5s%8.1f to%7.1f%8.1f", sLinearSegName[i][j], fLinearPtBA[i][j], fLinearPtBA[i][j+1], fLen), $('').addClass('wt').text(sprintf("%6.0f%8.0f", fLinearPtPpi[i][j], fLinearSegMaxWt[i][j]))[0] ) );

    0 讨论(0)
提交回复
热议问题