Skip to content

Instantly share code, notes, and snippets.

@RavenZZ
Created April 3, 2018 05:37
Show Gist options
  • Save RavenZZ/751e60336c12a396e9c77e5759bdcd1b to your computer and use it in GitHub Desktop.
Save RavenZZ/751e60336c12a396e9c77e5759bdcd1b to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"regexp"
)
func main() {
example := "#GoLa啊啊|ngCode!$!"
result := removeNonEng(example)
fmt.Printf("A string of %s becomes %s \n", example, result)
}
func removeNonEng(input string) string {
reg, err := regexp.Compile("[^a-zA-Z0-9]+")
if err != nil {
log.Fatal(err)
}
processedString := reg.ReplaceAllString(input, "")
return processedString
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment