It matches Chorus, Post-Chorus and Pre-Chorus blocks. I tried replacing the one in the code with this, and it actually stripes the Chorus blocks.
This part : (?=[\n]?$(?![\n])) is needed to match a Chorus|Post-Chorus|Pre-Chorus block that is at the very end of the lyrics (without a blank line after it).
A great option would be to be able to keep one chorus (and post-chorus etc.) but remove the duplicates, maybe just replacing them by [Chorus] only. This could probably be done in Regex too, but I guess doing it using string manipulation in JavaScript might be more readable and more flexible.
Hi, great lib, very easy to use and the doc is very nice too!
Maybe I'm mistaken but the removeChorus option doesn't work? I tried it and it didn't have any effect.
Checking the line removing the chorus there https://github.com/zyrouge/node-genius-lyrics/blob/1d8a8bbe4ef73ed4c06fdf400f7adadf97ac1414/lib/songs/song.ts#L127
the regex matching the chorus there is:
/^\[[^\]]+\]$/g
This doesn't seem to match anything (testing in regex101 with lyrics from Genius).
After a few tries, I found that this would seems to be a good regex to apply:
/^\[(?:Chorus|Post-Chorus|Pre-Chorus)[\s\S]*?(?:\n\n|(?=[\n]?$(?![\n])))/gm
It matches Chorus, Post-Chorus and Pre-Chorus blocks. I tried replacing the one in the code with this, and it actually stripes the Chorus blocks.
This part :
(?=[\n]?$(?![\n]))
is needed to match a Chorus|Post-Chorus|Pre-Chorus block that is at the very end of the lyrics (without a blank line after it).A great option would be to be able to keep one chorus (and post-chorus etc.) but remove the duplicates, maybe just replacing them by [Chorus] only. This could probably be done in Regex too, but I guess doing it using string manipulation in JavaScript might be more readable and more flexible.