Javascript can';t在js中通过双新行拆分文本

Javascript can';t在js中通过双新行拆分文本,javascript,php,Javascript,Php,我想用两行新行分割这个文本(歌曲),我使用ajax(FetchAPI)从php获得它 我试过next regex,但在我的js中没有一个不起作用 /\n{2,}/g /\n\r{2,}/ /\r\n{2,}|\r{2,}|\n{2,}/g 下面是我如何使用它的一行代码 let paragraphs = text.split(/\r\n{2,}|\r{2,}|\n{2,}/g); 不过,他们都很好,任何帮助将不胜感激,谢谢 PHP中的p.S.头已经检查了两次(JSON和UTF-8) 下一个给我

我想用两行新行分割这个文本(歌曲),我使用ajax(FetchAPI)从php获得它

我试过next regex,但在我的js中没有一个不起作用

/\n{2,}/g
/\n\r{2,}/
/\r\n{2,}|\r{2,}|\n{2,}/g
下面是我如何使用它的一行代码

let paragraphs = text.split(/\r\n{2,}|\r{2,}|\n{2,}/g);
不过,他们都很好,任何帮助将不胜感激,谢谢

PHP中的p.S.头已经检查了两次(JSON和UTF-8)

下一个给我

[
"You sad me goodbye
You did let me see
Then you[[em]] let me bye
So you let[[F]] me bye
know this can be
You know[[em]] I don't lie
This happened to me", // <--
"Remember - we[[D]] knew
I can't fit my mind
I'm feeling[[C]] so blue
Why you telling «bye»
So you let me bye
I know[[F]] this can be
You know I don't lie
This happened to me[[A]]", // <--
"This happened to me[[A]]
You sad me[[A]] goodbye
You did let me see
Then you let me[[A]] bye
So you let[[EM]] me bye
I know this can be
You know I don't lie
This happened to me[[A]]""
]

你认为
\n
(单个换行符)不是换行符,因为在正则表达式中,你希望所有换行符至少有两个
\n
?是的,因为在索纳塔包(Symfony 2.7+)中,我没有机会放置编辑器,所以用户只需输入一个纯文本
\r\n{2,}
是相等的
\r{1}\n{2,}
。使用
(\r\n){2,}
不,这不会有什么麻烦。你的意思是我错过了使用encodeURI(文本)检查@Smile0ff之间可能的空格,还有\s*cover\n | \r和spacesencodeURIComponent(文本)/encodeURI(文本)-都显示隐藏符号。如果你的正则表达式工作正常,但我不明白如何使它适应2次或更多的休息。它包含2次休息(至少)
text.split(/\n\s*\n/)
[
"You sad me goodbye
You did let me see
Then you[[em]] let me bye
So you let[[F]] me bye
know this can be
You know[[em]] I don't lie
This happened to me", // <--
"Remember - we[[D]] knew
I can't fit my mind
I'm feeling[[C]] so blue
Why you telling «bye»
So you let me bye
I know[[F]] this can be
You know I don't lie
This happened to me[[A]]", // <--
"This happened to me[[A]]
You sad me[[A]] goodbye
You did let me see
Then you let me[[A]] bye
So you let[[EM]] me bye
I know this can be
You know I don't lie
This happened to me[[A]]""
]
text.charCodeAt(151) // 10
text.charCodeAt(152) // 82 <--
'\n'.charCodeAt(0) // 10
'\r'.charCodeAt(0) // 13 <--