put regex outside of function
This commit is contained in:
parent
f056aa73c8
commit
3465296720
@ -65,6 +65,8 @@ type exportTemplateData struct {
|
||||
VarNames []string
|
||||
}
|
||||
|
||||
var isAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]*$`)
|
||||
|
||||
func generateFile(name string) string {
|
||||
fmt.Println("generating file for dictionary " + name)
|
||||
|
||||
@ -82,7 +84,7 @@ func generateFile(name string) string {
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
w := strings.TrimSpace(scanner.Text())
|
||||
if regexp.MustCompile(`^[a-zA-Z0-9]*$`).MatchString(w) {
|
||||
if isAlphaNumeric.MatchString(w) {
|
||||
words = append(words, w)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user