I have an array of characters like this :
chars := []string{".", "-", "(", ")"}
When I join them in regular way (strings.Join(chars, "")
) and pass it to regexp.MustCompile
, Its panic :
panic: regexp: Compile(`[.-()]`): error parsing regexp: invalid character class range: `.-(`
How can I scape string special characters for use in golang regexp as a character not regexp operator?