按字符NodeJS拆分字符串

我有一首歌,例如:

[Intro]

[Verse 1]
We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy

[Pre-Chorus 1]
I just wanna tell you how I'm feeling
Gotta make you understand

I want to split it by the [ character so then I now have three strings as such:

[Intro]
[Verse 1]
We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
[Pre-Chorus 1]
I just wanna tell you how I'm feeling
Gotta make you understand

并将它们保存为单独的字符串。

如何才能做到这一点?谢谢!

评论