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

前端 未结 1 1458
慢半拍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(
        $('<div>').append(
            sprintf("%5s%8.1f to%7.1f%8.1f", sLinearSegName[i][j], fLinearPtBA[i][j], fLinearPtBA[i][j+1], fLen),
            $('<span>').addClass('wt').text(sprintf("%6.0f%8.0f</span>", fLinearPtPpi[i][j], fLinearSegMaxWt[i][j]))[0]
        )
    );
    
    0 讨论(0)
提交回复
热议问题