Answer the question
In order to leave comments, you need to log in
How to write a regular expression with a variable inside?
How to correctly write a regular expression (specified in Compile() )?
myFile := значение_из_конфига
text := , err = ioutil.ReadFile("testFile.txt")
myRegexp, err = regexp.Compile(`начинается с " далее любые_символы_или_их_отсутствие далее myFile далее "`)
new_string := `"` + "prefix_" + myFile + `"`
strings.ReplaceAll(string(text), myRegexp, new_string)
Answer the question
In order to leave comments, you need to log in
Based on the context provided, I can assume what fmt.Sprintf
would be the easiest option in this situation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question