You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"regexp""fmt"
)
funcmain() {
// var re = regexp.MustCompile(`(=\s*)D\s+('.*?')`)varre=regexp.MustCompile(`(?m)(=\s*)D\s+('.*?')`)
varstr=`a = D '123' b`varsubstitution="$1xx$2"fmt.Println(re.ReplaceAllString(str, substitution))
}
expected: a = xx'123' b
actual: a '123' b
The text was updated successfully, but these errors were encountered:
ReplaceAllString treats the substitution string as though passed to Expand, and in Expand a $ may be followed by a name, and a name is a non-empty sequence of letters, digits, and underscores. So in your substitution string you are substituting $1xx (which is not defined) and then $2. Write instead ${1}xx${2}.
https://play.golang.org/p/G7VF0QgUxGi
expected:
a = xx'123' b
actual:
a '123' b
The text was updated successfully, but these errors were encountered: