我想用双新行分割这个文本(歌曲),我使用ajax(fetch API)从php中获取它
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]]"
我曾尝试过下一个正则表达式,但是它没有在我的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);
然而在https://regex101.com/它们一切正常,任何帮助都会受到赞赏,谢谢!
P.S。 PHP中的标题已经检查过两次(JSON和UTF-8)。
答案 0 :(得分:4)
[
"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.split(/\n\s*\n/).length // 3
text.charCodeAt(151) // 10
text.charCodeAt(152) // 82 <--
'\n'.charCodeAt(0) // 10
'\r'.charCodeAt(0) // 13 <--
关于您的代码
{{1}}