我有一根绳子:"快速的棕色狐狸跳过懒狗."
我想使用javascript(可能使用jQuery)每n个字符插入一个字符.例如,我想打电话:
var s = "The quick brown fox jumps over the lazy dogs.";
var new_s = UpdateString("$",5);
// new_s should equal "The q$uick $brown$ fox $jumps$ over$ the $lazy $dogs.$"
Run Code Online (Sandbox Code Playgroud)
目标是使用此函数插入并调整长字符串以允许它们换行.也许有人知道更好的方法?