我有我想分手的字符串文本。我需要通过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