Comment detail

文字列の均等分割 (Nested Flatten)

This comment is reply for 4235 にしお: 正規表現を使いました。 count...(文字列の均等分割). Go to thread root.

なるほどなるほど。では nongreedy なものを。
1
2
3
4
function doukaku88(n, s){
  for(var i = 0, m; !(m = s.match(RegExp('^'+ Array(n + 1).join('(.{'+ i +','+ ++i +'}?)') +'$'))););
  return m.slice(1);
}

Index

Feed

Other

Link

Pathtraq

loading...