Javascript根据行数将存储在字符串中的长文件拆分为字符串数组

Javascript根据行数将存储在字符串中的长文件拆分为字符串数组,javascript,Javascript,我已经找到了其他解决方案,但没有一个符合我的要求 假设我在var str中有一个包含以下数据的长文件: 我想根据新行将其分解为3个字符串的数组。因此,新数组,假设var strSplit有strSplit[0]: 我希望根据每一段文本之后的空白行来分割STR。我想不出来。您可以使用str.split/\r?\n\r?\n/;,拆分字符串;。请在下面查看 var str=`Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ip

我已经找到了其他解决方案,但没有一个符合我的要求

假设我在var str中有一个包含以下数据的长文件:

我想根据新行将其分解为3个字符串的数组。因此,新数组,假设var strSplit有strSplit[0]:

我希望根据每一段文本之后的空白行来分割STR。我想不出来。

您可以使用str.split/\r?\n\r?\n/;,拆分字符串;。请在下面查看

var str=`Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本; var result=str.split/\r?\n\r?\n/; console.logresult.lengthstr.split/\r\n\r\n | \n\n/
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry.