File size: 318 Bytes
7def60a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
package utils
import "regexp"
var matchNewlines = regexp.MustCompile(`[\r\n]`)
const doubleQuote = `"[^"\\]*(?:\\[\s\S][^"\\]*)*"`
func EscapeNewLines(s string) string {
return regexp.MustCompile(doubleQuote).ReplaceAllStringFunc(s, func(s string) string {
return matchNewlines.ReplaceAllString(s, "\\n")
})
}
|