Added ScriptEscape function
This commit is contained in:
parent
39c543ef1d
commit
8dc7cdb1cd
14
script.go
14
script.go
@ -1,5 +1,15 @@
|
|||||||
package mikrotik
|
package mikrotik
|
||||||
|
|
||||||
func Test() int {
|
import (
|
||||||
return 137
|
// 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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user