2023-08-23 09:33:02 +02:00
|
|
|
package mikrotik
|
|
|
|
|
2023-08-23 09:43:43 +02:00
|
|
|
import (
|
|
|
|
// Standard
|
|
|
|
"regexp"
|
|
|
|
)
|
|
|
|
|
2023-08-23 11:11:43 +02:00
|
|
|
func ScriptEscape(source string) (escaped string) {
|
2023-08-23 09:43:43 +02:00
|
|
|
rxp2 := regexp.MustCompile("([\"\\\\$])")
|
2023-08-23 11:11:43 +02:00
|
|
|
source = rxp2.ReplaceAllString(source, "\\$1")
|
2023-08-23 09:43:43 +02:00
|
|
|
|
|
|
|
rxp := regexp.MustCompile("\\r?\\n")
|
2023-08-23 11:11:43 +02:00
|
|
|
escaped = rxp.ReplaceAllString(source, "\\r\\\r\n \\n")
|
2023-08-23 09:43:43 +02:00
|
|
|
return
|
2023-08-23 09:33:02 +02:00
|
|
|
}
|