mikrotik/script.go

16 lines
309 B
Go

package mikrotik
import (
// Standard
"regexp"
)
func ScriptEscape(source []byte) (escaped []byte) {
rxp2 := regexp.MustCompile("([\"\\\\$])")
source = rxp2.ReplaceAll(source, []byte("\\$1"))
rxp := regexp.MustCompile("\\r?\\n")
escaped = rxp.ReplaceAll(source, []byte("\\r\\\r\n \\n"))
return
}