I have this JS function that I'm trying to translate to Go:
function splitByEmptyNewline(str) {
return str
.replace(/\r\n/g, '\n')
.split(/^\s*\n/gm);
}
Here's what I got so far:
func splitByEmptyNewline(str string) []string {
strNormalized := regexp.
MustCompile("\r\n").
ReplaceAllString(str, "\n")
return regexp.
MustCompile("^s*\n").
Split(strNormalized, -1)
}
This does not return the same result as the JavaScript version. So I'm wondering what I've missed?
I've tried using both double-quotes " and backward single-quotes ` for the regex.