我有我想分手的字符串文本。我需要通過Facebook信使聊天API發送它,但該API只允許640個字符,而我的文本要長得多。我想要一個整齊的解決方案,我可以通過它發送文本。在JavaScript中將包含多個段落的字符串分成兩部分
我是把包含多個段落的字符串拆分到最近的句號的兩半。
如
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