-2

JSでこの特定のphppregreplaceに相当するものはありますか?

preg_replace('/[\n]{2,}/', "\n", "Hi,\nHow are you?\n\n\nI am just testing");

ありがとうございました!

4

1 に答える 1

0

gフラグを指定する必要がありますが、基本的に同じです。

var theString = "Hi,\nHow are you?\n\n\nI am just testing";

theString = theString.replace(/\n{2,}/g, '\n');
于 2012-11-19T00:38:09.410 に答える