私は分割したい文字列を持っていました。私はFacebookのメッセンジャーチャットAPIを介してそれを送信する必要があったが、そのAPIは640文字しか許されず、テキストはかなり長くなります。私はテキストを送ることができるきちんとした解決策を求めていました。複数の段落を含む文字列をJavaScriptで2つの半分に分割する
複数の段落を含む弦を一番近いところまで2つに分割するものでした。
例:
var str = "This is paragraph one. I need Mr. Sam to my errand. The errand must be done by him. He is the best.
Mr. Sharma is also good. Btw this is the second paragraph. I think you get my point. Sentence again. Sentence again.
Paragraph three is started. I am writing so much now. This is fun. Thanks";
//Expected output
var half1 = "This is paragraph one. I need Mr. Sam to my errand. The errand must be done by him. He is the best.
Mr. Sharma is also good. Btw this is the second paragraph."
var half2 = "I think you get my point. Sentence again. Sentence again.
Paragraph three is started. I am writing so much now. This is fun. Thanks"
だから640文字を見て、戻ってあなたのように動作... – epascarello